Add call/ret/push/pop instructions

* Call/ret/push/pop are implemented and appear to be working
* Call/ret/push/pop is specified in the 0x2000 block, replacing the
  mov instruction
* Mov instruction is now specified in the 0x3000 block

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-02-26 10:14:48 -05:00
parent bd34cdad63
commit 7a6c2d80ab
8 changed files with 206 additions and 7 deletions

25
vm.md
View File

@@ -181,10 +181,33 @@ wrapping around to 0.
* Opcode: 0x1004
* Params: Source
## Functions
* Call
* Opcode: 0x2000
* Params: Source
* 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.
* Ret
* Opcode: 0x2001
* When this instruction is executed, these actions occur:
* Update the stack pointer to the current frame pointer + 16.
* Pop the IP of the next instruction.
* Pop the old stack frame.
* Restore the last three values in an undefined order
* Push
* Opcode: 0x2002
* Params: Source
* Pop
* Opcode: 0x2003
* Params: Dest
## Data movement
* Mov
* Opcode: 0x2000
* Opcode: 0x3000
## Miscellaneous