First page Back Continue Last page Overview Graphics
Checking for stack overflow
Stack Pointers and Frame Pointers
Recall that the stack is used for several purposes:
(1) it contains the return address for subroutine calls,
(2) it is used to preserve the values contained in registers when a subroutine is called,
(3) it can be used as a “scratch pad” to temporarily hold values needed for computation when not enough register space is available, and
(4) it can be used to pass arguments to and return values from subroutines.
To bring some order to our vision of the stack, and to conform to the conventions used in higher level languages, we will defineframes and discuss the use of the frame pointer, which is distinct from the stack pointer.
We will then discuss desirable properties of subroutines including position-independence and reentrancy which are important for recursive subroutines and those which may be called by multiple program threads.