Ngaro emulates a MISC (minimal instruction set computer) processor with 30 instructions. These are designed around a dual stack model, making it ideal for languages that are designed around a similar model, such as Forth. In fact, the primary assembler for 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.

The instructions follow.

  1. NOP
    • Does nothing
    • Opcode: 0
    • Stack Effect: -
  2. LIT
    • Push a literal to the stack
    • Opcode: 1 |value|
    • Stack Effect: -
  3. DUP
    • Duplicate the top value on the stack
    • Opcode: 2
    • Stack Effect: -
  4. DROP
    • Drop the top value off the stack
    • Opcode: 3
    • Stack Effect: -
  5. SWAP
    • Exchange the top and second item on the stack
    • Opcode: 4
    • Stack Effect: -
  6. PUSH
    • Push the top item on the data stack to the address stack
    • Opcode: 5
    • Stack Effect: -
  7. POP
    • Pop the top item on the address stack to the data stack
    • Opcode: 6
    • Stack Effect: -
  8. CALL
    • Call a subroutine
    • Opcode: 7 |address|
    • Stack Effect: -
  9. JUMP
    • Branch unconditionally to a memory location
    • Opcode: 8 |address|
    • Stack Effect: -
  10. ;
    • Return from a subroutine
    • Opcode: 9
    • Stack Effect: -
  11. >JUMP
    • Conditional branch, if NOS is greater than TOS
    • Opcode: 10 |address|
    • Stack Effect: -
  12. <JUMP
    • Conditional branch, if NOS is less than TOS
    • Opcode: 11 |address|
    • Stack Effect: -
  13. !JUMP
    • Conditional branch, if NOS is not equal to TOS
    • Opcode: 12 |address|
    • Stack Effect: -
  14. =JUMP
    • Conditional branch, if NOS is equal to TOS
    • Opcode: 13 |address|
    • Stack Effect: -
  15. @
    • Fetch the value at the memory address in TOS
    • Opcode: 14
    • Stack Effect: -
  16. !
    • Store the value on the second stack location to the address in TOS
    • Opcode: 15
    • Stack Effect: -
  17. +
    • Add the top two values on the stack
    • Opcode: 16
    • Stack Effect: -
  18. -
    • Subtract the top two values on the stack
    • Opcode: 17
    • Stack Effect: -
  19. *
    • Multiply the top two values on the stack
    • Opcode: 18
    • Stack Effect: -
  20. /MOD
    • Divide and get the remainder of the top two values on the stack
    • Opcode: 19
    • Stack Effect: -
  21. AND
    • Bitwise AND operation
    • Opcode: 20
    • Stack Effect: -
  22. OR
    • Bitwise OR operation
    • Opcode: 21
    • Stack Effect: -
  23. XOR
    • Bitwise XOR operation
    • Opcode: 22
    • Stack Effect: -
  24. <<
    • Shift bits left
    • Opcode: 23
    • Stack Effect: -
  25. >>
    • Shift bits right
    • Opcode: 24
    • Stack Effect: -
  26. 0;
    • Exit a subroutine and drop TOS if TOS is 0. If TOS is not 0, do nothing.
    • Opcode: 25
    • Stack Effect: -
  27. 1+
    • Increase the value on the stack by 1
    • Opcode: 26
    • Stack Effect: -
  28. 1-
    • Decrease the value on the stack by 1
    • Opcode: 27
    • Stack Effect: -
  29. IN
    • Read a value from a port
    • Opcode: 28
    • Stack Effect: -
  30. OUT
    • Send a value to a port
    • Opcode: 29
    • Stack Effect: -
  31. WAIT
    • Wait for the hardware to process an event.
    • Opcode: 30
    • Stack Effect: -
changed November 25, 2007