Definition: Stack. A stack is a data strucure used for storing and retrieving data. A stack is called a stack because the data is stored stacked on top of the data already in the stack; i.e., you PUSH it on the stack. Furthermore the data can only be accessed sequentially. I.e., you can only access the last data put on the stack; you POP it off. This last in first out nature of stacks inspired the name LIFO stack.
|Entry n - 1>|
|. . .|
How does the computer know where element n is? When you create a stack the computer points to the top of it with the stack pointer SP; register 14 (R14). Say you PUSH a longword (32 bits) on the stack (PUSHL) then the computer subtracts 4 (4 bytes = 32 bits) from the value contained in SP (R14). Why subtract? Stacks sit upside down in memory; i.e., they grow towards memory location 0. Now we can see how PUSH and POP work:
PUSHL R6 ; save the contents of register 6 on the stack MOVL R6,-(SP) ; this is equivalent to PUSHL R6
POPL R6 ;retrieve the value at the top of the stack into R6 ;remember that the top of the stack is it's lowest point ;in memory. MOVL (SP)+, R6 ;this is equivalent to POPL R6
When we POP we are using autoincrement mode. Here we move the value in the memory location pointed to by the value in SP to R6. Next we increment the value in SP by 4.
MACRO-32 has a POP and PUSH command (POPL for longwords (4 bytes), POPW for words (2 bytes)) but the VAX processor doesn't have a PUSH or POP instruction. The VAX processor makes use of autoincrementing and autodecementing so the single POP (or PUSH) command corresponds to a single instruction (we still have a 1:1 correspondence between the instruction set and assembly language commands); assembly commands are supposed to be mnemonics for machine instructions. But the PUSH and POP mnemonics are only there to make stack handling seem natural to programmers already familiar with other assemblers.