Stack-based memory allocation
Stacks are typically low-level programing functions involving memory following a a First-In Last-Out method or algorithm. A CPU stack is usually maintained in assembly level programming by special instructions the microprocessor has available in the CPU instruction set. For example, PUSH (Push a 8, 16 or 32-bit value to the stack) and POP (Take the top most 8, 16, or 32-bit value off of the stack) are two common instructions in most microprocessor's instruction set. A stack is a covenient way of passing parameters between routines in assembly language and excels particulary at nesting subroutines using JSR (Jump to SubRoutine) instruction with far (16 or 32-bit) pointers (vectors). For example, when calling a section of assembly code identified as a subroutine, we issue the JSR ABCDEF12 (some 32-bit memory address in hex). In order for the CPU to know which location to return to resume execution of the main loop when it reads the RTS (Return from Subroutine) instruction, the Program Counter of the CPU is automatically PUSH'ed onto the CPU's private stack. Each time a JSR command is issued, the NEXT location (the Program Counter always points to the next location where the next instruction or data will be read from in the memory address range) in memory from the JSR instruction is, er well, STACKED up in the CPU stack, much lack a stack of cards. The most recently added address will be the first to be read or POP'ped off the stack. So again, it is basically First-In Last-Out and this kind of process can be used in higher level languages as well by creating the appropriate data structure and indexing method.