NonStop S-Series Server Description Manual (G06.24+)
TNS Execution Modes
HP NonStop S-Series Server Description Manual—520331-003
6-54
Restoring a Stack Frame on Return From a Call
Restoring a Stack Frame on Return From a 
Call
A called procedure assumes full control of the process’s memory stack, accumulating 
and using the data in its own stack frame. When that procedure completes its 
operations and exits, the stack frame it was using is no longer needed and so is 
deleted.  The method for deleting the stack frame is to restore the L and S register 
settings to those that were in effect in the calling procedure at the time the call was 
made.
The following sequence and Figure 6-30 show how this restoration is accomplished. 
(This sequence is a continuation of the preceding topic.)
5. Procedure B allocates its local variables. In the same manner as procedure A 
did, procedure B generates its local variables. This increases the S register setting 
accordingly, so that the S register defines the new upper limit to B’s stack frame.
6. Procedure B exits back to procedure A.  When procedure B finishes, it executes 
an EXIT instruction to return to A. Execution of the EXIT instruction moves the 
L register setting back to the beginning of A’s local area and moves the S register 
setting back to the top-of-stack location that was in effect before the parameters 
were loaded on the stack for B. The new S register setting is derived from the old 
L register setting, because the L register contains the pointer to the stack marker 
that divides the two stack frames. The deletion of the parameter words is 
accomplished by use of the “S^decrement” value in the EXIT instruction.
The S^decrement value specifies how many word locations the S register should 
be set back from the old L register setting. Because, at the very least, the old 
stack marker needs to be deleted, the S^decrement value should at least be 3. 
Any value over that number will also delete words that precede the stack marker. 
Because the called procedure knows how many words preceding the stack marker 
must be passed to it as parameters, the EXIT instruction can be made to delete 
those words along with the stack marker.
In the case illustrated, for the return to procedure A, the EXIT instruction is:
EXIT 5
This deletes the three-word stack marker, plus the two parameter words, from the 
top of the stack—in addition to all of B’s local data. Procedure A is now back to 
where it was before the call was made.










