Assembling structured pointer-machine programs #
The pointer machine is a Program.FlatMachine for its instruction set (flatMachine), so a
structured program (Code) assembles into a flat list of instructions (Code.assemble) whose
conditionals and loops are tests and jumps to absolute labels. Every structured execution is a
run of the assembled program with exactly the same number of instructions (Exec.runs), so
bounds proved with the rules of Structured are bounds on the machine of Defs.
The assembled program followed by halt (Code.program) is an ordinary flat program, so it
composes with hand-written ones through Executes.inBlock, sequence and branch of Blocks.
Main definitions #
flatMachine: the instructions and steps of the pointer machine, for assembly.Code.assemble,Code.program: assembly at a given label, and the complete halting program.
Main results #
Exec.runs: a structured execution is a run of the assembled program inside any program.Exec.executes,ExecWithin.executes: it is a halting run of the complete program, with one more instruction for thehalt.
The pointer machine as a flat machine for its instruction set. A state of the flat machine is a label and a state whose own program counter is ignored.
Assembling c at any label gives c.size instructions.
Assembly is correct. A structured execution is a run of the assembled program placed after any prefix and before any suffix, from its first instruction to the label after it, with exactly the same number of instructions.
A structured execution within T instructions is a halting run of the complete program
within T + 1.