Instruction set

== TX-0 Instruction Set ==

The original Lincoln Labs TX-0 had only two bits of opcode and no index
register. The machine was moved to room 26-248 at MIT in July 1958 and
after about a year and a half the opcode field was extended to four bits
and an index register was added (ref. Computer Museum Report Vol 8, Spring 1984).

=== Original TX-0 Registers and Instruction Set ===
from "A Functional Description of the TX-0 Computer" Oct, 1958

==== Registers ====
* MBR - Memory Buffer Register (18 bits)
* AC - Accumulator (18 bits)
* MAR - Memory Address Register (16 bits)
* PC - Program Counter (16 bits)
* IR - Instruction Register (2 bits)
* LR - Live Register (18 bits)
* TBR - Toggle Switch Buffer Register (18 toggle switches)
* TAC - Toggle Switch Accumulator (18 toggle switches)

==== Basic Instructions ====

* 00 sto x Replace the contents of register x with the contents of the AC. Let the AC remain the same.
* 01 add x Add the word in register x to the contents of the AC and leave the sum in the AC
* 10 trn x If the sign digit of the accumulator (AC bit 0) is negative (i.e., a one) take the next instruction from register x and continue from there. If the sign is positive (i.e., a zero ignore this instruction and proceed to the next instruction
* 11 opr x Execute one of the operate class commands indicated by the number x

Operate Fields
--------------
--1 --- --- --- --- --- CLL
--- 1-- --- --- --- --- CLR
--- -10 --- --- --- --- IOS
--- -11 --- --- --- --- HLT
--- --- 111 --- --- --- P7H
--- --- 110 --- --- --- P6H
--- --- 100 --- --- --- PNT
--- --- 010 --- --- --- DIS
--- --- --- 10- --- --- SHR
--- --- --- 11- --- --- CYR
--- --- --- 01- --- --- MLR
--- --- --- --1 --- 0-- PEN
--- --- --- --0 --- 1-- TAC
--- --- --- --- 1-- --- COM
--- --- --- --- -1- --- PAD
--- --- --- --- --1 --- CRY
--- --- --- --- --- -01 AMB AC -> MBR
--- --- --- --- --- -11 TBR TBR -> MBR
--- --- --- --- --- -10 LMB LR -> MBR

==== Operate commands =====

700000 cll Clear the left nine digital positions of the AC
640000 clr Clear the right nine digital positions of the AC
620000 ios In-Out Stop
630000 hlt Halt the computer
607000 p7h Punch holes 1-6 in flexo tape Also punch a 7th hole on tape
606000 p6h Sam as p7h but no seventh hole
604000 pnt Print one flexowrite charater
601000 r1c Read one line of flexo tape
603000 r3c Read three lines of flexo tape
602000 dis Intesnsify a point on the scope from x,y in AC
600400 shr Shift the AC right one place
600600 cyr Cycle the AC right one digital position (AC17 -> AC0)
600100 pen Read the light pen flip flops 1 and 2 into AC0 and AC1
600004 tac Insert a one in each digital position of the AC whereever
there is a one in the corresponding digital position of the TAC
600040 com Complement every digit in the accumulator
600020 pad Partial add AC to MBR
600010 cry Partial add the 18 digits of the AC to the corresponding 18 digits
of the carry
600001 amb Store the contents of the AC in the MBR
600003 tbr Store the contents of the TBR in the MBR
600002 lmb Store the contents of the LR in the MBR

Combined Operate Class Commands

740000 cla cll + clr Clear the AC
600031 cyl amb + pad + cry Cycle the AC left one digital position
740040 clc cll + clr + com Clear and complement AC
622000 dis ios + dis Display (note IOS must be included for in-out cmds)
760000 ios + cll + clr In out stop with AC cleared
627600 ios + p7h + cyr Punch 7 holes and cycle AC right
626600 ios + p6h + cyr Punch 6 holes and cycle AC right
766000 ios + cll + clr + p6h Clear the AC and punch a blank space on tape
624600 ios + pnt + cyr Print and cycle AC right
627021 ios + p7h + amb + pad Punch 7 holes and leave AC cleared
626021 ios + p6h + amb + pad Punch 6 holes and leave AC cleared
624021 ios + pnt + amb + pad Print and leave AC cleared
741000 cll + clr + ric Clear AC and start PETR running (note computer hasn't
stopped to wait for information
601031 ric + amb + pad + cry Start PETR running and cycle AC left
601600 ric + cyr Start PETR running and cycle right
763000 cll + clr + ios + r3c Clear AC and read 3 lines of tape
761000 cll + clr + ios + ric Clear AC and read one line of tape
761031 cll + clr + ios + ric + pad + cry Read 1 line of tape and cycle AC left
761600 cll + clr + ios + ric + cyr Read 1 line of tape and cycle right
740004 cll + clr + tac Put contents of TAC in AC
600030 pad + cry Full-add the MBR and AC and leave sum in AC
740022 cll + clr + lmb + pad Clear the AC - store LR contents in memory buffer register
add memory buffer to AC - i.e., store live reg. contents
in AC (LAC)
600201 amb + mlr Store contents of AC in MBR, store contents of MBR in LR
i.e., store contents of AC in LR. (ALR)
600022 lmb + pad Store the contents of LR in MBR, partial add AC and MBR
i.e., partial add LR to AC. (LPD)
600200 mlr Since MLR alone will ahve a clear MBR, this is really
clear LR (LRO)
600032 lmb + pad + cry Full-add the LR to the AC (LAD)
740023 cll + clr + tbr + pad Store contents of TBR in AC

=== MIT Modified Registers and Instruction Set ===

==== Registers ====

* AC - 18 bit accumulator
* XR - 14 bit index register
* LR - 18 bit in-out register (live register)
* MBR - 18 bit memory buffer register
* TBR - Toggle Switch Buffer Register (18 toggle switches)
* TAC - Toggle Switch Accumulator (18 toggle switches)
* PF - program flag register (?)

Memo M-5001-29 "The Future TX-0 Instruction Code" dated September 23, 1960
describes these extensions. The notes here were derived from a later document
"TX-0 Instruction Set" with no author or date.

sto y 000000 + y Store
stx y 020000 + y Store AC, Indexed
sxa y 040000 + y Store Index in Address
ado y 060000 + y Add One
slr y 100000 + y Store Live Register
slx y 120000 + y Store LR Indexed
stz y 140000 + y Store Zero
add y 200000 + y Add the contents of register y to AC. Contents of y are unchanged
adx y 220000 + y Add, indexed
ldx y 240000 + y Load Index C(y)0 -> C(XR)4 C(y)5-17 -> C(XR)5-17
aux y 260000 + y Augment Index C(y)0,5-17 + C(XR) -> C(XR)
llr y 300000 + y Load Live Register
llx y 320000 + y Load LR, Indexed C(y + C(XR)) -> C(LR)
lda y 340000 + y Load Accumulator C(y) -> C(AC)
lax y 360000 + y Load Accumulator, Indexed C(y + C(XR)) -> C(AC)
trn y 400000 + y Transfer on Negative AC
tze y 420000 + y Transfer on Zero
tsx y 440000 + y Transfer and Set Index
tix y 460000 Transfer and Index
tra y 500000 + y Transfer y -> C(PC)
trx y 520000 + y Transfer, Indexed y + C(XR) -> C(PC)
tlv y 540000 + y Transfer on External Level

OPERATE CLASS MICRO-ORDERS
--------------------------

cla --1 --- --- --- --- --- Clear AC
amb --- 1-- --- --- --- --- Transfer AC contents to MBR
cyr --- --- --- 110 --- --- Cycle AC contents right one binary position (AC 17 -> AC 0)
shr --- --- --- 100 --- --- Shift AC contents right one binary position (AC 0 unchanged)
mbl --- --- --- 01x --- --- Transfer MBR contents to LR
xmb --- --- --- 0x1 --- --- Transfer XR contents to MBR
com --- --- --- --- 1-- --- Compliment AC
pad --- --- --- --- -1- --- Parital add MBR to AC (for each MBR one, complement the correp AC bit)
cry --- --- --- --- --1 --- A carry digit is a one if in the next least sigmificant digit,
either ac=0 and mbr=1 or ac=1 and carry digit=1. The carry digits
so determined are partial added to the AC by cry. pad and cry used
together give a full one's complement addition of C(MBR) to C(AC)
anb --- --- --- --- --- 111 And LR and MBR
orb --- --- --- --- --- 101 Or LR into MBR
lmb --- --- --- --- --- 01x Tranfer LR contents to MBR
mbx --- --- --- --- --- 0x1 Transfer MBR contents to XR

OPERATE CLASS COMMANDS WHICH CAN BE USED WITH MICRO-ORDERS SPECIFIED BY BITS 9-17
---------------------------------------------------------------------------------
nop 600000 perform no in-out group operation

tac 601000 transfer TAC contents to AC (inclusive or)
tbr 602000 transfer TBR contents to MBR (inclusive or)
pen 603000 set AC bit 0 from light pen ff and ac bit 1 from light gun ff
rpf 606000 Read Program Flag register into MBR (inclusive or)
spf 607000 Set Program Flag register from MBR

ex0 610000 operate external equipment
.. ..
ex7 617000

cpy 620000 copy synchronizes transmission of information between io equp & computer
r1l 621000 read one line of tape from PETR into AC bits 0, 3, 6, 9, 12
dis 622000 display a point on the scope (AC bis 0-8 = X, 9-17 = Y)
r3l 623000 read three lines of tape from PETR AC bits 0, 3, 6, 9, 12, 15
prt 624000 print one six bit flexo character from ac bits 2,5,8,11,14,17
p6h 626000 punch one six bit line of flexo tape w/o 7th hole from ac 2,5,8,11,14,17
p7h 627000 same as -6h but with 7th hole

hlt 630000 halt the computer and sound chime
cll 631000 Clear Left 9 bits of AC
clr 632000 Clear Right 9 bits of AC

OPERATE CLASS INSTRUCTIONS RECOGNIZED BY MIDAS
----------------------------------------------
MNEMONIC OCTAL VALUE OPERATION

opr 600000 No operation
xro 600001 Clear XR to +0
lxr 600003 Place LR in XR
cry 600012 Carry the contents of AC according to bits of LR
lpd 600022 Logical exclusive or of AC is placed in AC (partial add)
lad 600032 Add LR to AC
com 600040 Compliment the AC
lcd 600072 Contents of LR minus those of AC are placed in AC
xad 600130 Add index register to accumulator
xcd 600170 Contents of XR minus those of AC are placed in AC
lro 600200 Clear LR to +0
xlr 600300 Place XR in LR
ixl 600303 Interchange XR and LR
shr 600400 Shift accumulator right one place, bit 0
remains unchanged
cyr 600600 Cycle AC right one place

pen 603000 Contents of light pen and light cannon flip-flops replace
contents of AC bits 0 and 1. The flip-flops are cleared.

bsr 604000 Backspace tape unit by one record
rtb 604004 Read tape binary (odd parity)
rds 604004 Select tape unit for reading a record
rew 604010 Rewind tape unit
wtb 604014 Write tape binary (odd parity)
wrs 604014 Select tape unit for writing a record
rtd 604024 Read tape decimal (even parity)
wtd 604034 Write tape decimal (even parity)

cpf 607000 The program flag is cleared

cpy 620000 Transmit information between the live register and
selected input-output unit

dis 622000 Display point on CRT corresponding to contents of AC

prt 624000 Print one on-line flexo character from bits 2, 5, etc.
pnt 624600 PRT, then cycle AC right once to set up another character
typ 625000 Read one character from on-line flexowriter into LR bits 12-17
p6h 626600 Punch one line of paper tape; 6 holes from bits 2, 5, etc.
of AC then cycle right once.
p7h 627600 Same as p6h, but punch 7th hole

hlt 630000 Stops computer
cll 631000 Clear left half of AC to zero
clr 632000 Clear right half of AC

axr 640001 Place AC contents in XR
axo 640021 AXR, then set AC to +0
cyl 640030 Cycle AC left one place
alx 640031 AXR, then cycle AC left once
amz 640040 Add minus zero to AC
axc 640061 AXR, then set AC to -0
alr 640200 Place accumulator contents in live register
rax 640203 Place LR in XR, then place AC in LR
orl 640205 Logical or of AC and LR is placed in LR
anl 640207 Logical and of AC and LR is placed in LR
alo 640220 ALR, then set AC to +0
all 640230 ALR, then cycle left once
iad 640232 Interchange and add AC contents are placed in the LR and
the previous contents of the LR ar added to AC
alc 640260 ALR, then set AC to -0
arx 640601 AXR, then cycle AC right once
spf 647000 Place AC in program flag register

dso 662020 DIS, then clear AC
pno 664020 PRT, then clear AC
pnc 664060 PRT, then clear AC to -0
p6o 666020 p6h then clear AC
p7o 667020 p7h then clear AC

cla 700000 Clear entire AC to +0
cax 700001 Clear AC and XR to +0
lal 700012 Place LR in AC cycled left once
lac 700022 Place LR in AC
clc 700040 Clear and complement: set AC to -0
lcc 700062 Place complement of LR in AC
laz 700072 Add LR to minus zero in AC
xal 700110 XAC, then cycle AC left once
xac 700120 Place index register in accumulator
xcc 700160 Place complement of XR in accumulator
cal 700200 Clear AC and LR to +0
rxe 700322 Place LR in AC, then place XR in LR
lar 700622 Place LR in AC cycled right once
tac 701000 Contents of test accumulator are placed in AC
tbr 702020 Contents of test buffer register are placed in AC
rpf 706020 The program flag register is placed in AC

rlc 721000 Read one line paper tape into AC bits 0, 3, etc.
rlr 721600 rlc, then cycle AC right once
r3c 723000 Read three lines of paper tape
p6a 726000 Clear AC and punch a line of blank tape
ora 740025 Logical or of AC and LR is placed in AC
ana 740027 Logical and of AC and LR is placed in AC
anc 740207 ANL, then clear AC
oro 740205 ORL, then clear AC
ial 740222 Interchange AC and LR
p6b 766020 Punch a line of blank tape, but save AC

----------------------------
MIT Modified Instruction Set
March 1961
----------------------------

This is the TX-0 instruction set defined in Macro ii-a
March 1961. There is no index register, and instructions
marked with a '*' do not appear in MIDAS.

sto 0
slr 100000
add 200000
llr 300000
trn 400000
tra 500000
opr 600000 NOP
cry 600012
lpd 600022
cyl* 600031
lad 600032
com 600040
amz* 600051
lcd 600072
pen 600100 600300 in MIDAS
orl* 600105
ora* 600125
lro 600200
alr* 600201 | logical instrs change?
ala* 600221 |
alc* 600261 |
anl* 600305 |
ana* 600325 V
shr 600400
cyr 600600
bsr 604000
rds 604004 No even parity R/W (604024/604034)
rew 604010
wrs 604014
cpf 607000
spf* 607001
cpy 620000
dis 622000
dsa* 622021
dsc* 622061
prt 624000
pna* 624021
pnc* 624061
pnt 624600
p6a* 626021
p6h 626600
p7a* 627021
p7h 627600
hlt 630000
clr* 640000