First page Back Continue Last page Overview Graphics
Note that the stack pointer points to the top of the stack.
The frame pointer corresponding to a particular subroutine call is fixed and points to the return address of the subroutine.
- Local variables require negative offset from the frame pointer (because they were placed on the stack after the return address).
- Passed parameters require a positive offset because they were placed on the stack before the subroutine call.
If the processor stack grows towards lower memory locations, the stack pointer is decremented when data is pushed and incremented when data is pulled or popped. If the processor stack grows towards higher memory locations, the stack pointer is incremented when data is pushed and decremented when data is pulled or popped.
This determines the sign of the offsets from the frame pointer for local variables and passed parameters. The conventions above correspond to the processor we are using.