Figure 1 shows the stack frame layout ( Figure 1 shows the stack frame layout for AMODE64). The stack register points to a location 2048 bytes before the stack frame for the currently active routine. It grows from numerically higher storage addresses to numerically lower ones, that is the stack frame for a called function is normally at a lower address than the calling function. The stack frame is quadword-aligned.
Table 1 describes the contents of each area within the stack frame shown in Figure 1.
Stack frame area | Content |
---|---|
Save area | This area is always present when a stack frame
is required. It holds up to 12 registers. The first two words hold,
optionally, GPRs 4 and 5, the registers containing the address of
the previous stack frame and the environment address passed into the
function. This is followed by the two words containing GPR6, which
may or may not hold the actual entry point address depending on the
type of call, and GPR7, the return address. As many of the 8 non-volatile
registers as are used by the called function are saved in the following
32 bytes. Except when registers are saved in the prolog, this area may not be altered by compiled code. The PPA1 GPR Save Mask indicates which GPRs are saved in this area by the prolog. Stack overflow is detected by the STM or STMY instruction used to save registers in this save area. Storage of the Backchain field in the save area is triggered by the optional XPLINK(BACKCHAIN) compiler option (or at the convenience of the compiler). The Environment Address is stored when the TEST compiler option or the optional XPLINK(STOREARGS) compiler option is specified, or at the convenience of the compiler. The
third slot in the save area contains the value in GPR6 on entry to
the routine. If the routine was called with a BASR instruction, the
address is that of the function entry point. The fourth slot contains
the return address. The return point can be examined to determine
how the function was called:
|
Reserved | This area is always present and is for the exclusive use of the runtime. It is uninitialized by compiled code. |
Debugger area | This area is always present and is for the exclusive use of the debugger. It is uninitialized by compiled code. |
Argument area prefix | This area is used for parameter mapping (hidden parameter) to accommodate calls between new and old code. It is uninitialized by compiled code. |
Argument area | This area is at the fixed DSA offset of 64 bytes into the caller's stack frame. It contains the argument lists passed on function calls made by the function associated with this stack frame. The called function finds its parameters in the caller's stack frame. A minimum of 4 words (16 bytes) must be always be allocated. |
Local storage | This is the space owned by the executing procedure and may be used for its local variables and temporaries. |