tz
tz is a MISC (minimal instruction set) virtual computer.
architecture
- 29 instructions
- cells are 32-bit signed integers
- I/O is done via device calls (INT instruction)
- memory: 65,536 cells (256KiB)
- data stack: 64 cells
- return stack: 128 cells
instruction reference
hex octal mnemonic effect description
-------------------------------------------------------------------
0x01 001 LIT (-n) push immediate value into stack
0x02 002 DUP (n-nn) duplicate top stack item
0x03 003 SWAP (xy-yx) reverse top two stack items
0x04 004 ZAP (x-) discard top stack item
0x05 005 PUSH (x-) move top of stack to return stack
0x06 006 POP (-x) move top of return stack to data stack
0x07 007 JUMP (a-) jump to address
0x08 010 JMPF (af-) jump to address if flag is set
0x09 011 CALL (a-) call subroutine
0x0A 012 CALF (af-) call subroutine if flag is set
0x0B 013 RET (-) return from subroutine
0x0C 014 LOAD (a-n) load value from memory
0x0D 015 STOR (an-) store value to address in memory
0x0E 016 RLOD (a-n) load register
0x0F 017 RSTO (an-) store value to register
0x10 020 EQ (xy-f) test for equality
0x11 021 NEQ (xy-f) test for inequality
0x12 022 GT (xy-f) test if X is greater than Y
0x13 023 LT (xy-f) test if X is lesser than Y
0x14 024 ADD (xy-z) x + y
0x15 025 SUB (xy-z) x - y
0x16 026 MUL (xy-z) x * y
0x17 027 DIV (xy-zw) x / y and x % y
0x18 030 AND (xy-z) x & y
0x19 031 OR (xy-z) x | y
0x1A 032 XOR (xy-z) x ^ y
0x1B 033 NOT (x-x) ~x
0x1C 034 SHFT (xy-z) logical shift
0x1D 035 INT (n-) interact with device
I/O device reference
in tz, I/O is implemented using device calls. which devices are available is
implementation-defined, but the following three are mandatory:
0 CORE (n-n) processor registers query (sp, rp, ip)
1 PUTC (n-) generic character output
2 GETC (-n) generic character input