══════════════════════════════════════════════════════════ Description of the ternary computer TRIADOR ══════════════════════════════════════════════════════════ General purpose registers trits 2 1 0 (a trit can take -1,0,+1 values) ┌─┬─┬─┐ R1│ │ │ │ \ ├─┼─┼─┤ | Program memory R2│ │ │ │ | trits 4 3 2 1 0 ├─┼─┼─┤ |-- main set ┌─┬─┬─┬─┬─┐ R3│ │ │ │ | of registers a -364│ │ │ │ │ │ ├─┼─┼─┤ | d ├─┼─┼─┼─┼─┤ R4│ │ │ │ / d -363│ │ │ │ │ │ ├─┼─┼─┤ r ├─┼─┼─┼─┼─┤ R5│ │ │ │ \ e -362│ │ │ │ │ │ ├─┼─┼─┤ | s ├─┼─┼─┼─┼─┤ R6│ │ │ │ | s : : : : : : ├─┼─┼─┤ | ├─┼─┼─┼─┼─┤ R7│ │ │ │ | -1 │ │ │ │ │ │ ├─┼─┼─┤ | ├─┼─┼─┼─┼─┤ R8│ │ │ │ | 0 │ │ │ │ │ │ ├─┼─┼─┤ |-- extra registers ├─┼─┼─┼─┼─┤ R9│ │ │ │ | +1 │ │ │ │ │ │ ├─┼─┼─┤ | ├─┼─┼─┼─┼─┤ R10│ │ │ │ | : : : : : : ├─┼─┼─┤ | ├─┼─┼─┼─┼─┤ R11│ │ │ │ | +363│ │ │ │ │ │ ├─┼─┼─┤ | ├─┼─┼─┼─┼─┤ R12│ │ │ │ / +364│ │ │ │ │ │ ├─┼─┼─┤ └─┴─┴─┴─┴─┘ R13│ │ │ │ Special register, └─┴─┴─┘ specifies memory segment for JP ttt ┌─┬─┬─┬─┬─┬─┐ PC │ │ │ │ │ │ │ program counter register (-364..+364) └─┴─┴─┴─┴─┴─┘ ┌─┐ C │ │ borrow/carry flag (+1 borrow, -1 carry) └─┘ Every 3-trit register can take values from -13 to +13: t2*9 + t1*3 + t0 where t0,t1,t2 - trits (-1,0,+1) ═══════════════════════════════════════════════════════════ TRIADOR instruction set ═══════════════════════════════════════════════════════════ (for lisibility we use N,O,P instead of -1,0,+1) ┌───────┬────────┬───────────────────────────────────────┐ │op code│mnemonic│ description │ ├───────┼────────┼───────────────────────────────────────┤ │ NNttt │ EX ttt │ extension commands (work in progress) │ ├───────┼────────┼───────────────────────────────────────┤ │ NOttt │ JP ttt │ unconditional jump to R13*27+ttt │ ├───────┼────────┼───────────────────────────────────────┤ │ NPttt │ SK ttt │ conditional skips of the next command │ ├───────┼────────┼───────────────────────────────────────┤ │ ONttt │ OP ttt │ tritwise unary operation over R1 │ ├───────┼────────┼───────────────────────────────────────┤ │ OOttt │ RR ttt │ copying between registers │ ├───────┼────────┼───────────────────────────────────────┤ │ OPttt │ R1 ttt │ write ttt to the register R1 │ ├───────┼────────┼───────────────────────────────────────┤ │ PNttt │ R2 ttt │ write ttt to the register R2 │ ├───────┼────────┼───────────────────────────────────────┤ │ POttt │ R3 ttt │ write ttt to the register R3 │ ├───────┼────────┼───────────────────────────────────────┤ │ PPttt │ R4 ttt │ write ttt to the register R4 │ └───────┴────────┴───────────────────────────────────────┘ Additional comments: - ttt means a 3-trit number with values from NNN (-13) to PPP (+13) - RR ttt instruction copies a register to/from R1 or performs an increment/decrement over R1 OONNN — copy R1 to R13 OONNO — copy R1 to R12 OONNP — copy R1 to R11 OONON — copy R1 to R10 OONOO — copy R1 to R9 OONOP — copy R1 to R8 OOPON — copy R1 to R7 OOPOO — copy R1 to R6 OOPOP — copy R1 to R5 OOONN — copy R1 to R4 OOONO — copy R1 to R3 OOONP — copy R1 to R2 OOOON — decrement R1, set borrow/carry flag OOOOO — no operation OOOOP — increment R1, set borrow/carry flag OOOPN — copy R2 to R1 OOOPO — copy R3 to R1 OOOPP — copy R4 to R1 OOPNN — copy R5 to R1 OOPNO — copy R6 to R1 OOPNP — copy R7 to R1 OOPON — copy R8 to R1 OOPOO — copy R9 to R1 OOPOP — copy R10 to R1 OOPPN — copy R11 to R1 OOPPO — copy R12 to R1 OOPPP — copy R13 to R1 - SK ttt skips one instruction depending on the sign of R1,R2,R3,R4 or the borrow/carry flag C: NPNNN - skip if R4 >= 0 NPNNO - skip if R4 != 0 NPNNP - skip if R4 <= 0 NPNON - skip if R3 >= 0 NPNOO - skip if R3 != 0 NPNOP - skip if R3 <= 0 NPNPN - skip if R2 >= 0 NPNPO - skip if R2 != 0 NPNPP - skip if R2 <= 0 NPONN - skip if R1 >= 0 NPONO - skip if R1 != 0 NPONP - skip if R1 <= 0 NPOON - skip if C == -1 NPOOO - skip if C == 0 NPOOP - skip if C == 1 NPOPN - skip if R1 < 0 NPOPO - skip if R1 == 0 NPOPP - skip if R1 > 0 NPPNN - skip if R2 < 0 NPPNO - skip if R2 == 0 NPPNP - skip if R2 > 0 NPPON - skip if R3 < 0 NPPOO - skip if R3 == 0 NPPOP - skip if R3 > 0 NPPPN - skip if R4 < 0 NPPPO - skip if R4 == 0 NPPPP - skip if R4 > 0