![](images/spacer.gif) | ![](images/spacer.gif) | ![](images/spacer.gif) |
![](images/spacer.gif) | Quote: -4 N: triad from memory addressed by DPn (see below); -3 O: triad from memory addressed by DPo (see below); -2 P: triad from memory addressed by DPp (see below); -1 F: flag register (see below); 0 A: accumulator register; +1 B: auxiliary register; +2 L: lower triad of current DP register (see below); +3 M: middle triad of current DP register (see below); +4 H: higher triad of current DP register (see below);
Register F is set of 3 flags: Higher trit: RSF (Result Sign Flag) Middle trit: DPF (Data Pointer Flag) Lower trit: BCF (Borrow Carry Flag)
There are 3 9-trit DP (data pointer) registers - DPn, DPo, DPp, available through L/M/H when flag DPF has corresponding value (N, O, P).
So full set of opcodes is: #NNN (-13) SAN - save register A to register N; #NNO (-12) SAO - save register A to register O; #NNP (-11) SAP - save register A to register P; #NON (-10) SAF - save register A to register F; #NOO (-9) SPCD - save PC (program counter) to current data pointer; #NOP (-8) SAB - save register A to register B; #NPN (-7) SAL - save register A to register L (lower triade of current data pointer); #NPO (-6) SAM - save register A to register M (middle triade of current data pointer); #NPP (-5) SAH - save register A to register H (higher triade of current data pointer); #ONN (-4) RLA - rotate register A to the left through flag BCF; #ONO (-3) ADD - add register A with B and flag BCF, save result to A and BCF, modify sign flag RSF; #ONP (-2) RRA - rotate register A to the right through flag BCF; #OON (-1) LAI # - load register A from immediate triad; #OOO (0) ADI # - add register A with immediate triad and flag BCF, save result to A and BCF, modify sign flag RSF; #OOP (1) OPA # - perform unary "tritwise" operation over register A (function set by immediate triad), modify sign flag RSF; #OPN (2) LDI # # # - load current data pointer by immediate 3 triads (higher, middle, lower); #OPO (3) JMP # # # - jump to address set by immediate 3 triads (put it to register PC: higher, middle, lower); #OPP (4) OPB # # # - perform binary "tritwise" operation over registers A and B, save result to A (function set by immediate 3 triad), modify sign flag RSF; #PNN (5) LAN - load register A from register N; #PNO (6) LAO - load register A from register O; #PNP (7) LAP - load register A from register P; #PON (8) LAF - load register A from register F; #POO (9) LPCD - load PC (program counter) from current data pointer; #POP (10) LAB - load register A from register B; #PPN (11) LAL - load register A from register L (lower triad of current data pointer); #PPO (12) LAM - load register A from register M (middle triad of current data pointer); #PPP (13) LAH - load register A from register H (higher triad of current data pointer);
| ![](images/spacer.gif) |
![](images/spacer.gif) | ![](images/spacer.gif) | ![](images/spacer.gif) |
Today I finished full emulator of this command set! A few days ago I designed "user interface" of first prototype my ternary computer. It consists of line of ternary LEDs and line of ternary switches. 9 LEDs always display state of PC, 3 LEDs display ternary data (see below) and 3 more LEDs always display state of accumulator register A. 9 switches set some address, 3 switches set some data and 3 more switches are control ones. So we have totally 15 LEDs and 15 switches. Control switches:
1) input/output ternary switch:
P (top position) - using specified address write data to the memory (data LEDs display this 3-trit data);
O (neutral position) - ignore address and data switches (data LEDs display data from memory address PC);
N (bottom position) - ignore data switches and display data from specified address;
2) subprogram ternary switch:
P (top position) - interrupt main program, save current PC and jump to specified address;
O (neutral position) - do not disturb working program;
N (bottom position) - stop subprogram and restore PC to return to main program;
3) step/run ternary switch:
P (top position) - execute one step of the program;
O (neutral position) - pause mode;
N (bottom position) - run program from current position.
Emulation program is a little bit smaller than 1000 lines of Java-code:
http://www.nedopc.org/ternary/java.php?applet=3