NonStop S-Series Server Description Manual (G06.24+)

Native Execution Mode
HP NonStop S-Series Server Description Manual520331-003
7-4
RISC Stack Frames
RISC Stack Frames
The primary stacks used by a native process (that is, the main stack and the privileged
stack) use RISC stack frame conventions as illustrated in Figure 7-2. These stacks
grow downward, toward smaller addresses. They both originate at the high-address
end of their containing segments. (In diagrams throughout this manual, addresses are
shown as increasing downward on the page.)
The sp (stack pointer) register points at the stack tip, which is the lowest-addressed
byte in the current stack frame. Typically, sp is static for the frame and, in most cases,
also serves as the frame pointer for the current frame. (If a procedure has
dynamically allocated variables, a separate frame pointer register is used as the static
reference point for the frame and sp is adjusted to the new tip.) The frame pointer is
used as a base reference to address local variables, saved registers, and formal
parameters.
The virtual frame pointer (vfp) defines the frame origin. The origin is the trailing
edge of the stack frame. It coincides with the tip of the frame of the caller. Thus, sp for
the caller becomes vfp for the called procedure. No register actually contains the vfp
address.
As shown in Figure 7-2, the formal parameters of a procedure call can be considered
part of either or both frames—the caller’s and the called. The caller’s procedure frame
is allocated with enough call-out space to hold the parameters for any procedure that it
might invoke. Actual parameters are stored into this space by offset references to sp
(not pushed, as in TNS frames). The called procedure addresses the formal
parameters by offsets from its own frame pointer.
Native stack frames can be increased only in multiples of eight bytes, and sp is
rounded up as necessary to accommodate this convention.
Subprocedures use exactly the same stack format as procedures, and sp is adjusted
each time any nested subprocedure is called. To accommodate the need for
subprocedures to access the outer procedure’s local variables, the outer procedure’s
vfp address is passed as a hidden parameter in the v0 register.