Author: mesyeti <mesyeti@mesyeti.uk>
update isa
man/vm.md | 17 +++++++++++++---- vm/source/vm.h | 4 ++--
diff --git a/man/vm.md b/man/vm.md index 11d07f26035fbcb8c3594168948e617fc5ff9d57..4e1519bb64b3ac2a36f9ed031e641e7c13781917 100644 --- a/man/vm.md +++ b/man/vm.md @@ -1,7 +1,16 @@ # Nitron VM +## Opcodes +Opcodes have this format +| `76543210` | +| ---------- | +| `IOOOOOOO` | + +- `I` means the 32 bit word after the instruction is pushed before running the instruction +- `O` is the opcode + ## Instructions -- VM_INST_NOP (`0x00`) - - Does nothing +- VM_INST_HALT (`0x00`) `( -- )` + - Halts the virtual machine - VM_INST_ADD (`0x01`) `( a b -- a+b )` - Adds 2 integers and returns the result - VM_INST_SUB (`0x02`) `( a b -- a-b )` @@ -32,8 +41,8 @@ - VM_INST_JUMP (`0x0E`) `( addr -- )` - Jumps to the given address - VM_INST_JNZ (`0x0F`) `( v addr -- )` - Jumps to the given address if the value below the address is not 0 -- VM_INST_HALT (`0x10`) `( -- )` - - Halts the virtual machine +- VM_INST_NOP (`0x10`) + - Does nothing - VM_INST_SYSCALL (`0x11`) - Pops the given system call ID and calls it, see system calls section - VM_INST_REG (`0x12`) `( reg -- v)` diff --git a/vm/source/vm.h b/vm/source/vm.h index 6ec93f406c712d7acfb6e938dbd573a0dcf28af9..45ffbac7e5350d8d79d20dbdc7b0ecc04e3dc28f 100644 --- a/vm/source/vm.h +++ b/vm/source/vm.h @@ -2,7 +2,7 @@ #ifndef N_VM_H #define N_VM_H enum { - VM_INST_NOP = 0x00, + VM_INST_HALT = 0x00, VM_INST_ADD = 0x01, VM_INST_SUB = 0x02, VM_INST_MUL = 0x03, @@ -18,7 +18,7 @@ VM_INST_READ = 0x0C, VM_INST_WRITE = 0x0D, VM_INST_JUMP = 0x0E, VM_INST_JNZ = 0x0F, - VM_INST_HALT = 0x10, + VM_INST_NOP = 0x10, VM_INST_SYSCALL = 0x11, VM_INST_REG = 0x12, VM_INST_WREG = 0x13,