Programming the Gigatron
Programming the Gigatron
This page is about my own attempt to understand and program the Gigatron TTL Color Micro-computer. I made use of the files on<br>kervinck/gigatron-rom at<br>GitHub.<br>Disclaimer: this is not an official Gigatron page and I am not responsible<br>for errors it contains. This page could become outdated in case a new revision<br>of the ROM is released.
CPU
The CPU implemented by the TTL IC's of the Gigatron has a<br>Harvard<br>architecture, which means that it does not have a shared bus for the ROM<br>and the RAM. Actually, the ROM is only used to store instructions and there<br>are no instruction to access the ROM directly. (Nevertheless, there is a clever trick by which it is possible to 'read' data from the ROM.) The<br>CPU is an 8-bit processor with a 14-bit program counter and a 15-bit RAM range.<br>It has three 8-bit registers and an 8-bit input and output.
CPU instructions
I rewrote the gtemu.c program such that it would print out what the<br>different instruction actually do in some pseudo-C. After a lot of revisions,<br>this resulted in the following table. The numbers on the rows and columns need<br>to be added together to get the instruction number. I changed the order of the<br>rows such that similar (or the same) instrucions are grouped together. The<br>'function' hi returns the high byte of the value. It should be noted<br>that the value used to access the RAM is 'clipped' to 0x7fff as there is only<br>32 kilobyte of RAM. The program counter is incremented after all instructions,<br>except the instructions that modify it. In case an instruction performs two<br>operations, a semi-collon is used for separation.
# 00 # 20 # 40 # 60 # 80 # a0 # c0 # e0<br>---+-----------------------+---------------------------+---------------------------+---------------------------+---------------------------+---------------------------+--------------------------+---------------------------------<br>00 # A = oper # A &= oper # A |= oper # A ^= oper # A += oper # A -= oper # RAM[oper] = oper # PC = (Y>>8)|oper<br>04 # A = oper # A &= oper # A |= oper # A ^= oper # A += oper # A -= oper # RAM[X] = oper # if (A >8)|oper] = oper # if (A > 0) PC = hi(PC)|oper<br>0c # A = oper # A &= oper # A |= oper # A ^= oper # A += oper # A -= oper # RAM[(Y>>8)|X] = oper # if (A != 0) PC = hi(PC)|oper<br>10 # X = oper # X = A & oper # X = A | oper # X = A ^ oper # X = A + oper # X = A - oper # RAM[oper] = oper; X = A # if (A == 0) PC = hi(PC)|oper<br>14 # Y = oper # Y = A & oper # Y = A | oper # Y = A ^ oper # Y = A + oper # Y = A - oper # RAM[oper] = oper; Y = A # if (A = 0) PC = hi(PC)|oper<br>1c # OUT = oper; X++ # OUT = A & oper; X++ # OUT = A | oper; X++ # OUT = A ^ oper; X++ # OUT = A + oper; X++ # OUT = A - oper; X++ # RAM[(Y>>8)|X++] = oper # PC = hi(PC)|oper<br>01 # A = RAM[oper] # A &= RAM[oper] # A |= RAM[oper] # A ^= RAM[oper] # A += RAM[oper] # A -= RAM[oper] # RAM[oper] = undef # PC = (Y>>8)|RAM[oper]<br>05 # A = RAM[X] # A &= RAM[X] # A |= RAM[X] # A ^= RAM[X] # A += RAM[X] # A -= RAM[X] # RAM[X] = undef # if (A >8)|oper] # A &= RAM[(Y>>8)|oper] # A |= RAM[(Y>>8)|oper] # A ^= RAM[(Y>>8)|oper] # A += RAM[(Y>>8)|oper] # A -= RAM[(Y>>8)|oper] # RAM[(Y>>8)|oper] = undef # if (A > 0) PC = hi(PC)|RAM[oper]<br>0d # A = RAM[(Y>>8)|X] # A &= RAM[(Y>>8)|X] # A |= RAM[(Y>>8)|X] # A ^= RAM[(Y>>8)|X] # A += RAM[(Y>>8)|X] # A -= RAM[(Y>>8)|X] # RAM[(Y>>8)|X] = undef # if (A != 0) PC = hi(PC)|RAM[oper]<br>11 # X = RAM[oper] # X = A & RAM[oper] # X = A | RAM[oper] # X = A ^ RAM[oper] # X = A + RAM[oper] # X = A - RAM[oper] # RAM[oper] = undef; X = A # if (A == 0) PC = hi(PC)|RAM[oper]<br>15 # Y = RAM[oper] # Y = A & RAM[oper] # Y = A | RAM[oper] # Y = A ^ RAM[oper] # Y = A + RAM[oper] # Y = A - RAM[oper] # RAM[oper] = undef; Y = A # if (A = 0) PC = hi(PC)|RAM[oper]<br>1d # OUT = RAM[(Y>>8)|X++] # OUT = A & RAM[(Y>>8)|X++] # OUT = A | RAM[(Y>>8)|X++] # OUT = A ^ RAM[(Y>>8)|X++] # OUT = A + RAM[(Y>>8)|X++] # OUT = A - RAM[(Y>>8)|X++] # RAM[(Y>>8)|X++] = undef # PC = hi(PC)|RAM[oper]<br>02 # /*nop*/ # /*nop*/ # /*nop*/ # A = 0 # A *= 2 # A = 0 # RAM[oper] = A # PC = (Y>>8)|A<br>06 # /*nop*/ # /*nop*/ # /*nop*/ # A = 0 # A *= 2 # A = 0 # RAM[X] = A # if (A >8)|oper] = A # if (A > 0) PC = hi(PC)|A<br>0e # /*nop*/ # /*nop*/ # /*nop*/ # A = 0 # A *= 2 # A = 0 # RAM[(Y>>8)|X] = A # if (A != 0) PC = hi(PC)|A<br>12 # X = A # X = A # X = A # X = 0 # X = 2*A # X = 0 # RAM[oper] = A; X = A # if (A == 0) PC = hi(PC)|A<br>16 # Y = A # Y = A # Y = A # Y = 0 # Y = 2*A # Y = 0 # RAM[oper] = A; Y = A # if (A = 0) PC = hi(PC)|A<br>1e # OUT = A; X++ # OUT = A; X++ # OUT = A; X++ # OUT = 0; X++ # OUT = 2*A; X++ # OUT = 0; X++ # RAM[(Y>>8)|X++] = A # PC = hi(PC)|A<br>03 # A = IN # A &= IN # A |= IN # A ^= IN # A += IN # A -= IN # RAM[oper] = IN # PC = (Y>>8)|IN<br>07 # A = IN # A &= IN # A |= IN # A ^= IN # A += IN # A -= IN # RAM[X] = IN # if (A >8)|oper] = IN # if (A > 0) PC = hi(PC)|IN<br>0f # A = IN # A &= IN # A |= IN # A ^= IN # A += IN # A -= IN # RAM[(Y>>8)|X] = IN # if (A != 0) PC = hi(PC)|IN<br>13 # X = IN # X = A & IN...