Tny Reference

Memory map




  1. The ROM gets loaded in the RAM
  2. The IP (Instruction Pointer) starts at position 2
  3. Every instruction is executed
  4. A BRK instruction will stop execution of current vector
  5. The address stored at memory position 0 is the screen vector, executed 60 times per second
  6. The address stored at memory position 1 is the key vector, executed when a key is pressed


Code Mnemonic Effect Purpose
0x00 BRK Stop evaluation
0x01 RET Pop rstack into IP
0x02 JMP a Set the IP to a
0x03 JMR a Push IP+1 to rstack, then JMP
0x04 JCN f a Set IP to a if f is not 0
0x05 JCR f a Push IP+1 to rstack, then JCN
0x06 LIT Push following number to the stack, increase IP by 2
0x07 POP n Pop top of the stack
0x08 DUP n -- n n Duplicate top of the stack
0x09 SWP n1 n2 -- n2 n1 Swap top of the stack
0x0a ROT n1 n2 n3 -- n2 n3 n1 Rotate top of the stack
0x0b OVR n1 n2 -- n1 n2 n1 Copy n1 to top of the stack
0x0c PSH n -- Take value off pstack and push it to rstack
0x0d PUL -- n Pull value off rstack and push it to pstack
0x0e RSI -- n Copy top of rstack without affecting it
0x0f RSJ -- n Copy second item of rstack without affecting it
0x10 STA n a Store n to address
0x11 LDA a -- n Load from address
0x12 STB n a Store n in buffer at address a
0x13 LDB a -- n Load from buffer address a
0x14 ADD n1 n2 -- n1+n2 Add top two stack values
0x15 SUB n1 n2 -- n1-n2 Subtract top stack value from second
0x16 INC n -- n+1 Increment top of the stack
0x17 DEC n -- n-1 Decrement top of the stack
0x18 MUL n1 n2 -- n1*n2 Multiply top two stack values
0x19 DIV n1 n2 -- n1/n2 Divide top two stack values
0x1a MOD n1 n2 -- n1%n2 Divide n1 by n2 and push remainder
0x1b RND -- n Push random number
0x1c EQU n1 n2 -- f Check if n1 and n2 are equal
0x1d NEQ n1 n2 -- f Check if n1 and n2 are different
0x1e GTH n1 n2 -- f Check if n1 > n2
0x1f LTH n1 n2 -- f Check if n1 < n2
0x20 AND n1 n2 -- n1&n2 Push n1 & n2 to the stack
0x21 ORR n1 n2 -- n1|n2 Push the binary OR operation n1|n2 to the stack
0x22 XOR n1 n2 -- n1^n2 Push the binary XOR operation n1^n2 to the stack
0x23 SFT n ctl -- v Shift n left based on ctl high nibble, right based on ctl low nibble.
0x24 CLS Clear screen
0x25 SET a f Set pixel at a when f is 1.
0x26 GET a -- f Get state of pixel at adr. 1 if on, 0 otherwise.
0x27 KEY k Push the value of the controller to the pstack
0x28 FRM f Push the value of the current frame to the pstack