11.2. Activation Record.   

When a procedure calls another procedure (even itself) the state of that procedure must be saved = its activation environment must be saved. In a structured language the space for this is taken from a stack so that the runtime stack may be composed of many activation records as procedures call other procedures.

Remember that not just the return address is put on the stack

with recursion or nesting of procedures and hence deep
recursion can quickly cause a STACK OVERFLOW.

When the procedure returns, the stored activation record of the calling procedure is "reloaded" and execution continues from that point indicated by the INSTRUCTION POINTER.

The data frame is also reclaimed from the stack.


-------------
(A) Activation (1) Pointer to current activation
Environment environment is at A.
of current (2) When procedure (2) is called, pointer
procedure moves to B and new environment is stored
------------- (3) When a return is executed the pointer
(B) Activation at B returns the pointer to (A) and
Environment "dead" environment.
-------------
Compare this with PL0.
What does a call do?
What does an OPR, 0, 0 do?

CALL:

S[T+1] BASE(L);
S[T+2] B;
S[T+3] P;
B T+1;
P a;

OPR 0,0:

t b-1;
P S[t+3];
b s[t+2];

Notice for the call that the top-of-stack pointer is not changed. Surely this is an error otherwise the first LIT or LOD will destroy the BASE(L) or B or P?
What is the answer?

How does RETURN reclaim the stack data frame?

      Summary  of

actions for a procedure activation

CALL:

(1) Allocate space for data frame (activation record) of
called procedure/function.
(2) Process parameters appropriately and place in reserved
location in data frame (or static memory).
(3) Set up pointers to other environments to allow access to
other data frames of textually enclosing
blocks/procedures/functions.
(4) Save current environment and create new values for new
activation.
(5) Stop execution of current procedure and start new.
RETURN:
(1) STORE result in some place if function.
(2) "Reload" calling environment.
(3) Stop execution of called procedure and resume execution
of calling procedure.