Guardian Programmer's Guide

Table Of Contents
Managing Memory
Guardian Programmer’s Guide 421922-014
17 - 4
Managing the TNS User Data Segment
S (stack) register points to the last entry in the stack; in this case, it points to the
dummy stack marker.
When the main procedure executes, its local variables get added to the stack as
shown in Figure 17-2(b). The S register points to the last location of the local
variables.
When the main procedure calls another procedure (procedure 1 in Figure 17-2), the
parameters for the new procedure are placed on the data stack followed by the
contents of the P (program counter) register, E (environment) register, and L (local data
address) register. Then the new procedure’s local variables are placed on the stack
(see Figure 17-2(c)). The S register points to the last location of the local variables of
the new procedure.
Figure 17-2(d) shows what happens when procedure 1 calls procedure 2. Again the
parameters for the new procedure are placed on the stack followed by the contents of
the P register, E register, and L register. The S register is advanced to the last location
of the local variables of procedure 2. Additional procedures can be nested in this way.