Procedure Activation
1. What Happens on Call/Return
Activation = creating a frame for one execution of a procedure; deactivation = destroying it on return. Caller saves state, callee builds frame, runs, restores.
caller: evaluate args → save registers/fp → push params + return addr → jump to callee
callee: push fp (control link) → set fp=sp → alloc locals → run body
return: put value in return slot/reg → restore sp,fp,pc → caller resumes + cleans args
Recursion works because each call gets a fresh frame — locals do not clash.
4. Displays for Nesting
Deeply nested languages keep a display (array of fp per level) for O(1) nonlocal access instead of chasing access links.
5. Exam Points
- List call/return steps in order — 7 marks, very frequent.
- Draw stack with two active frames — 5 marks, frequent.
- Why stack enables recursion (vs static) — 3 marks, frequent.