A fantasy console.
This is a work in progress, spec is not finalised.
Stack-machine, 8-bit ALU, 16-bit addresses (MMU allows access to 1MB). PPU with internal VRAM. Tile based display.
Stack effect notation (a b -- c) shows inputs before the dash, outputs after.
| Category | Code | Syntax | Stack Effect | Description |
|---|---|---|---|---|
| System | 00 | ZZZ | ( -- ) | No operation. |
| 01 | SYS n | varies | Call system routine n, e.g. dump, trace. | |
| 0F | HLT | ( -- ) | Halt system. | |
| Stack operations | 20 | POP | (a -- ) | Discard top of stack |
| 21 | DUP | (a -- a a) | Duplicate top item | |
| 22 | SWP | (a b -- b a) | Swap top two items | |
| 23 | OVR | (a b -- a b a) | Copy 2nd item to top | |
| 24 | ROT | (a b c -- b c a) | Rotate top three left; use ROT ROT for right rotation |
|
| 25 | NIP | (a b -- b) | Drop 2nd item; equivalent to SWP POP |
|
| 26 | TUC | (a b -- b a b) | Tuck copy of top under 2nd; equivalent to SWP OVR |
|
| Literals & addressing | 30 | ST1 | (a lo hi -- ) | Store byte a at address (lo hi) |
| 31 | ST2 | (a lo hi -- ) | Store 16-bit value a at address (lo hi) | |
| 32 | LD1 | (lo hi -- a) | Load byte from address (lo hi) | |
| 33 | LD2 | (lo hi -- a) | Load 16-bit value from address (lo hi) | |
| 34 | IM1 n | ( -- n) | Push next byte literal | |
| 35 | IM2 n16 | ( -- lo hi) | Push next 2-byte literal | |
| ALU (8-bit unless noted) | 40 | ADD | (a b -- c) | Add a + b (wraparound) |
| 41 | SUB | (a b -- c) | Subtract a − b | |
| 42 | AND | (a b -- c) | Bitwise AND | |
| 43 | IOR | (a b -- c) | Bitwise OR | |
| 44 | XOR | (a b -- c) | Bitwise XOR | |
| 45 | NOT | (a -- ~a) | Bitwise NOT | |
| 46 | BSL | (a n -- c) | Shift a left by n bits | |
| 47 | BRL | (a n -- c) | Rotate a left by n bits | |
| Control flow | 50 | CAL addr16 | ( -- ) | Call subroutine (like JSR) |
| 51 | RTN | (cond -- ) | Return if non-zero | |
| 52 | RTZ | (cond -- ) | Return if zero | |
| 53 | RET | ( -- ) | Unconditional return | |
| 54 | HOP rel8 | ( -- ) | Relative jump (signed offset) | |
| 55 | SKP | (addr -- ) | Jump to address on stack | |
| 56 | JMP addr16 | ( -- ) | Absolute jump | |
| 57 | RSW | (a -- ) | Push a to return stack | |
| 58 | RSR | ( -- a) | Pop from return stack | |
| System, I/O & timing | 60 | VBL | ( -- ) | Wait for vertical blank |
| 61 | SYS | ( -- ) | Call system routine n | |
| 62 | PUT | (val -- ) | Write value to I/O port n | |
| 63 | GET | ( -- val) | Read byte from I/O port n |