AbstractSyntax #
This module provides core abstract-syntax types of the MRiscX assembly language.
Purpose of this file: This file establishes the syntax of the MRiscX assembly language, encompassing the definition of instructions, labels, registers, memory and machine states. Given that the instructionsMap, labels, registers, and memory are represented as maps, it may be beneficial to review the contents of the file Maps.lean beforehand.
Next we define some Datatypes for the map keys. This is because it makes it easier to understand which map is being processed. Firstly a register, which will hold a value
Instances For
Equations
- instCoeRegisterUInt64 = { coe := fun (c : Register) => c }
Next, the memory address. This address will point to a certain address in the memory which holds some value
Equations
Instances For
The InstructionIndex is a serial number which points to a instruction in the stack
Equations
Instances For
The program counter: the index of the instruction currently being executed.
Equations
Instances For
A total map which holds the instructions of a program tied to a unsigned 64-bit integers as InstructionIndex. The default value of this map is the instruction Instr.Panic.
IM := {uint64_1 ↦ instr_1, uint64_2 ↦ instr_2, ..., uint64_n ↦ instr_n} / default: Instr.IPanic
Equations
Instances For
Equations
- instReprInstructionMap = { reprPrec := instReprInstructionMap._aux_1 }
Equations
Equations
- instToStringInstructionMap = { toString := fun (instrMap : InstructionMap) => reprStr instrMap }
Empty InstructionMap which serves as standard InstructionMap
Equations
Instances For
Equations
- instReprLabelMap = { reprPrec := instReprLabelMap._aux_1 }
Equations
- instInhabitedLabelMap = { default := instInhabitedLabelMap._aux_1 }
Empty LabelMap which serves as standard LabelMap
Equations
Instances For
The InstructionMap and the LabelMap are combined into a single structure,
which is refered as Code.
- instructionMap : InstructionMap
The instruction map, associating each instruction index with an instruction.
- labels : LabelMap
The label map, associating each label name with its target index.
Instances For
A default instance of Code, containing an empty InstructionMap and an empty LabelMap.
Equations
- DefaultCode = { instructionMap := EmptyInstructionMap, labels := EmptyLabels }
Instances For
Add a list of (name, index) label bindings to a Code.
Equations
- m.addMultipleLabels [] = m
- m.addMultipleLabels (h :: t) = { instructionMap := m.instructionMap, labels := p(h.fst ↦ h.snd; m.labels) }.addMultipleLabels t
Instances For
Insert both an instruction and a label binding into a Code.
Equations
Instances For
Look up the instruction stored at index l in a Code.
Equations
- m.getInstrAt l = TMap.get m.instructionMap l
Instances For
Equations
- instReprRegisters = { reprPrec := instReprRegisters._aux_1 }
RegisterMap with default value 0
R := {r_1 ↦ w_1, … , r_k ↦ w_k; 0}
Equations
Instances For
Equations
- instReprMemory = { reprPrec := instReprMemory._aux_1 }
MemoryMap with default value 0
M := {m_1 ↦ w_1, … , m_k ↦ w_k; 0}