The stack

The stack is a portion of storage that is used to hold local storage, register save areas, parameter lists, and call-chain data.

The stack grows from higher addresses to lower addresses. A stack pointer register (register 1) is used to mark the current top of the stack.

A stack frame is the portion of the stack that is used by a single procedure. In either case, the stack frame size is best defined as the difference between the caller's stack pointer and the callee's.

The following diagrams show the storage maps of typical stack frames for 32-bit and 64-bit environments.

In these diagrams, the current routine has acquired a stack frame that allows it to call other functions. If the routine does not make any calls and there are no local variables or temporaries, the function need not allocate a stack frame. It can use the register save area at the top of where the callee's stack frame would have been, if needed.

The stack frame is quadword aligned. The FPR save area (which must contain an even number of FPRs), the VR save area and the parameter area (P1, P2, ..., Pn) are quadword aligned. In 64-bit mode the GPR save area is doubleword aligned. Other areas require word alignment only.

The following diagram shows the storage map of a typical stack frame for a 32-bit environment.

Figure 1. Runtime Stack for 32-bit Environment - Vector Information not Included
Runtime Stack for 32-bit Environment - Vector Information not Included
Figure 2. Runtime Stack for 32-bit Environment
Runtime Stack for 32-bit Environment

The following diagram shows the storage map of a typical stack frame for a 64-bit environment.

Figure 3. Runtime Stack for 64-bit Environment
Runtime Stack for 64-bit Environment