Update spec to reflect previous changes

This adds R00-R31 preservation to interrupts and adds meta section
required values.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-03-10 12:21:29 -04:00
parent 85e5f7a2bf
commit 7c9d4fe908

30
vm.md
View File

@@ -199,7 +199,7 @@ wrapping around to 0.
* When this instruction is executed, these actions occur:
* Push the current stack frame pointer
* Push the IP of the next instruction
* Update the IP (i.e., jump) to the value at the given source.
* Update the IP to the value at the given source.
* Update the frame pointer to the current stack pointer - 16
* Ret
* Opcode: 0x3001
@@ -229,7 +229,7 @@ wrapping around to 0.
* Push the FLAGS register
* Push the STATUS register
* Push the R0-R31 registers
* Update the IP (i.e., jump) to the address of the given interrupt vector in the IVT
* Update the IP to the address of the given interrupt vector in the IVT
* Update the R0 register to the value in the first parameter
* Update the R1 register to the value in the second parameter
* Update the frame pointer to the current stack pointer - 288
@@ -237,13 +237,11 @@ wrapping around to 0.
* Opcode: 0x3005
* When this instruction is executed, these actions occur:
* Update the stack pointer to the current frame pointer + 288
* Pop the old R1 value
* Pop the old R0 value
* Pop the old R31-R00 values
* Pop the old STATUS value
* Pop the old FLAGS value
* Pop the IP of the next instruction
* Pop the old stack frame
* Restore the last 6 values in an undefined order
## Data movement
@@ -306,20 +304,21 @@ Before an interrupt handler is called, these actions occur:
* Push the IP of the next instruction to be called
* Push the FLAGS register
* Push the STATUS register
* Push the R0 register
* Push the R1 register
* Push the R0-R31 registers
* Update the IP to the address of the given interrupt vector in the IVT
* Update the R0 register to the value in the first parameter
* Update the R1 register to the value in the second parameter
* Update the frame pointer to the current stack pointer - 288
Interrupt handlers must be exited using the `iret` instruction. When an interrupt call is exited,
the above actions occur in reverse:
* Update the stack pointer to the current frame pointer + 48
* Pop the old R1 value
* Pop the old R0 value
* Update the stack pointer to the current frame pointer + 288
* Pop the old R31-R00 values
* Pop the old STATUS value
* Pop the old FLAGS value
* Pop the IP of the next instruction
* Pop the old stack frame
* Restore the last 6 values in an undefined order
## Exceptions
@@ -405,7 +404,14 @@ executing program. Data in the meta section is not copied to the program memory.
A VM must provide support for the following meta-values:
* `entry` - a 64-bit address for where the VM should begin executing code.
* `ip` - the initial value for the instruction pointer (the entry point)
* `fp` - the initial value for the stack frame pointer
* If not set, its default value is the value of the stack pointer.
* `sp` - the initial value for the stack pointer
* `flags` - the initial CPU flags
* `status` - the initial value for the status register
* `ivt` - the initial value for the pointer to the IVT
* `rXX` - the initial value for register XX (0-31)
# General TODO