You are on page 1of 5

ngaro .jo t t it .

co m

https://ngaro .jo ttit.co m/instructio nset

Ngaro VM
Ngaro emulates a MISC (minimal instruction set computer) processor with 31 instructions. T hese are designed around a dual stack model, making it ideal f or languages that are designed around a similar model, such as Forth. In f act, the primary assembler f or the instruction set is a Machine Forth dialect. If an unsupported opcode is encountered, the internal IP register is set to the end of memory. Execution of the image code will halt when this happens. T he instructions f ollow. 1. NOP Does nothing Opcode: 0 Stack Ef f ect: 2. LIT Push a literal to the stack Opcode: 1 |value| Stack Ef f ect: 3. DUP Duplicate the top value on the stack Opcode: 2 Stack Ef f ect: 4. DROP Drop the top value of f the stack Opcode: 3 Stack Ef f ect: 5. SWAP Exchange the top and second item on the stack Opcode: 4 Stack Ef f ect: 6. PUSH Push the top item on the data stack to the address stack Opcode: 5 Stack Ef f ect: -

7. POP Pop the top item on the address stack to the data stack Opcode: 6 Stack Ef f ect: 8. CALL Call a subroutine Opcode: 7 |address| Stack Ef f ect: 9. JUMP Branch unconditionally to a memory location Opcode: 8 |address| Stack Ef f ect: 10. ; Return f rom a subroutine Opcode: 9 Stack Ef f ect: 11. >JUMP Conditional branch, if NOS is greater than T OS Opcode: 10 |address| Stack Ef f ect: 12. Conditional branch, if NOS is less than T OS Opcode: 11 |address| Stack Ef f ect: 13. !JUMP Conditional branch, if NOS is not equal to T OS Opcode: 12 |address| Stack Ef f ect: 14. =JUMP Conditional branch, if NOS is equal to T OS Opcode: 13 |address| Stack Ef f ect: -

15. @ Fetch the value at the memory address in T OS Opcode: 14 Stack Ef f ect: 16. ! Store the value on the second stack location to the address in T OS Opcode: 15 Stack Ef f ect: 17. + Add the top two values on the stack Opcode: 16 Stack Ef f ect: 18. Subtract the top two values on the stack Opcode: 17 Stack Ef f ect: 19. * Multiply the top two values on the stack Opcode: 18 Stack Ef f ect: 20. /MOD Divide and get the remainder of the top two values on the stack Opcode: 19 Stack Ef f ect: 21. AND Bitwise AND operation Opcode: 20 Stack Ef f ect: 22. OR Bitwise OR operation Opcode: 21 Stack Ef f ect: 23. XOR

23. XOR Bitwise XOR operation Opcode: 22 Stack Ef f ect: 24. << Shif t bits lef t Opcode: 23 Stack Ef f ect: 25. >> Shif t bits right Opcode: 24 Stack Ef f ect: 26. 0; Exit a subroutine and drop T OS if T OS is 0. If T OS is not 0, do nothing. Opcode: 25 Stack Ef f ect: 27. 1+ Increase the value on the stack by 1 Opcode: 26 Stack Ef f ect: 28. 1Decrease the value on the stack by 1 Opcode: 27 Stack Ef f ect: 29. IN Read a value f rom a port Opcode: 28 Stack Ef f ect: 30. OUT Send a value to a port Opcode: 29 Stack Ef f ect: 31. WAIT

Wait f or the hardware to process an event. Opcode: 30 Stack Ef f ect: -

You might also like