Each instruction has an explicit data, stack, and control contract.
Classify the registers read and written by every controller instruction, then execute a micro-controller that uses every supported instruction.
What must a reader know about one instruction before reasoning about a complete controller?
- Summarize register reads and writes for each instruction tag
- Distinguish stack effects from register effects
- Distinguish next, conditional, direct, indirect, and halt control
- Recognize constant, register, label, and operation sources
- Execute a controller containing every instruction in the supported subset
instruction-summary treats controller text as data. It recursively extracts register sources from operation expressions, identifies the destination of assign and restore, records push or pop effects, and classifies how the pc changes. A branch reads the flag rather than an ordinary register; a label goto is direct while a register goto reads its target from a register.
The micro-controller then exercises the same reference against execution. It assigns constants and an operation result, saves and restores val, stores a label position in continue, jumps indirectly through that register, tests, takes a branch, performs an observable operation, and halts. The summary is the exact reference for this finite simulator subset.
- Output
- —
- Value
- —
- Diagnostic
- —
The summary program returns contracts for assign, test, branch, goto, save, restore, perform, and halt in that order. The micro-controller returns (complete 10 #t 12 (10)).
Compare each static contract with its executed transition. In particular, follow save and restore without a visible final stack value, the label source stored in continue, the indirect goto, the flag-setting test, and the true branch that skips the -1 assignment.
Change the program and compare the result.
Add a second goto that uses a label source and a perform instruction with two register operands. Update the static summaries before running the controller.
Show hint
A direct label goto reads no ordinary register. A perform instruction reads every register found recursively inside its operation source.