Tny

Tny Reference

Memory map

Screen

000102030405060708090a0b0c0d0e0f
101112131415161718191a1b1c1d1e1f
202122232425262728292a2b2c2d2e2f
303132333435363738393a3b3c3d3e3f
404142434445464748494a4b4c4d4e4f
505152535455565758595a5b5c5d5e5f
606162636465666768696a6b6c6d6e6f
707172737475767778797a7b7c7d7e7f
808182838485868788898a8b8c8d8e8f
909192939495969798999a9b9c9d9e9f
a0a1a2a3a4a5a6a7a8a9aaabacadaeaf
b0b1b2b3b4b5b6b7b8b9babbbcbdbebf
c0c1c2c3c4c5c6c7c8c9cacbcccdcecf
d0d1d2d3d4d5d6d7d8d9dadbdcdddedf
e0e1e2e3e4e5e6e7e8e9eaebecedeeef
f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff

Execution

  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

Instructions

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