Program flow and function calls. Four worksheets in worksheets/ch8/ complete the VM. Recursive factorial runs on your silicon; gdb traces stack frames.
Anchors the week
Week 9: VM II. Labels and conditional jumps; the full function-call protocol with caller-save and callee-save; recursion as a free byproduct.
Concept the lab embodies
Composition under stack discipline. Once function calls work cleanly, arbitrary recursive structure works; the stack does the bookkeeping.
The four worksheets
| Worksheet | Time | Purpose |
|---|---|---|
| lab-8.1-program-flow-translator.md | ~90 min | label, goto, if-goto |
| lab-8.2-function-call-protocol-translator.md | ~120 min | call, function, return |
| lab-8.3-recursive-factorial-on-silicon.md | ~90 min | First recursive program on your CPU |
| lab-8.4-gdb-on-running-frame-trace.md | ~90 min | gdb backtrace on a running frame |
Grading rubric
Per-worksheet rubrics. Week-level: function-call protocol round-trips correctly; recursive factorial(8) returns 40320 on silicon; gdb shows nested stack frames during execution.
What's next
Lab pack 9: Compiler I. The compiler frontend.