Everything is now brought together in a single structure called MState, which represents the machine's MState This structure holds the memory, registers, the code, a program counter (PC), and a termination flag. The program counter points to the next instruction to be executed, while the termination flag indicates whether the machine state has halted or if further evaluation should continue.
The state of the abstract machine: its memory, registers, program counter, loaded code, and termination flag.
- memory : Memory
The data memory of the machine.
- registers : Registers
The register file of the machine.
- pc : ProgramCounter
The program counter, pointing at the next instruction to execute.
- code : Code
The program (code) loaded into the machine.
- terminated : Bool
Whether the machine has halted.
Instances For
The initial machine state: empty memory and registers, program counter 0,
not terminated, and the default code.
Equations
- DefaultMState = { memory := EmptyMemory, registers := EmptyRegisters, pc := 0, code := DefaultCode, terminated := false }
Instances For
The instruction at the current program counter.
Equations
- ms.currInstruction = TMap.get ms.code.instructionMap ms.pc
Instances For
Replace the register file with r.
Equations
- ms.setRegister r = { memory := ms.memory, registers := r, pc := ms.pc, code := ms.code, terminated := ms.terminated }
Instances For
Replace the instruction map of the loaded code.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Replace the label map of the loaded code.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Build a fresh machine state running the code c.
Equations
- MState.createStandardState c = { memory := DefaultMState.memory, registers := DefaultMState.registers, pc := DefaultMState.pc, code := c, terminated := DefaultMState.terminated }
Instances For
This creates a Machine state with the pointer which the label [s] points to. If there is no label [s] in code.labels, terminated is set to true.
Equations
- One or more equations did not get rendered due to their size.