notes.org 1.2 KB

5.2 A Register Machine Simulator

one way to test our machine design is to carry out the state during operations by hand. but that would be silly!! lol. it's a scheme program with 4 interface procedures:

  • (make-machine reg-names operations controller)

  • (set-register-contents! machine-model reg-name value)

  • (get-register-contents machine-model reg-name)

  • (start machine-model)

5.2.1 the machine model

make-machine extends the basic machine model with a message passing technique.

it has registers holding value as local state. we can get and set.

the stack is likewise a procedure with local state. we can push, pop, and initialize to empty.

5.2.2 the assembler

the assembler transforms a series of controller expressions into a corresponding list of machine instructions.

(assemble controller-text machine)

5.2.3 generating execution procedures for instructions

this is some wild shit! true galaxy brain takes.

implementing the fundamental instructions of the machine.

assign, test, branch, goto, save, restore, perform, primitive exp

5.2.4 monitoring machine performance

we can verify not only correctness of a machine design, but also measure its performance

cool souped up stack implementation