Next, we write the whole program, including data, instructions, and table. We want to add 9 + 7. That is, we want to calculate C=A+B where A is 9, B is 7, and C is the answer. The underlining and italics are just to highlight data for the person reading the program and do not affect the program. In instr_4, the first two 16-bit words of data don't matter because no bits are copied.

Addition Program

 label        address            data          comment

start    0000000000000000  0000000000010000  start 0000000000000100
A        0000000000000001  0000000000001001  9 (A)
B        0000000000000010  0000000000000111  7 (B)
C        0000000000000011  0000000000000000  answer (C)
instr_1  0000000000000100  0000000000000001  from address of A
         0000000000000101  0000000000001100  to instr_3's from addr.
         0000000000000110  0000000011110000  copy to these bits
         0000000000000111  0000000000100100  go to instr_2, rot. 4
instr_2  0000000000001000  0000000000000010  from address of B
         0000000000001001  0000000000001100  to instr_3's from addr.
         0000000000001010  0000000000001111  copy to these bits
         0000000000001011  0000000000110000  go to instr_3, no rot.
instr_3  0000000000001100  0000001000000000  from addtable
         0000000000001101  0000000000000011  to address of C
         0000000000001110  0000000011111111  copy to these bits
         0000000000001111  0000000001000000  go to instr_4, no rot.
instr_4  0000000000010000  0000000000000000  doesn't matter
         0000000000010001  0000000000000000  doesn't matter
         0000000000010010  0000000000000000  copy NO bits
         0000000000010011  0000000001000000  go to this instruction

addtable 0000001000000000  0000000000000000  0 + 0 = 00
         0000001000000001  0000000000000001  0 + 1 = 01
         0000001000000010  0000000000000010  0 + 2 = 02
                                 .
                                 .
                                 .
         0000001010010110  0000000000010101  9 + 6 = 15
         0000001010010111  0000000000010110  9 + 7 = 16
         0000001010011000  0000000000010111  9 + 8 = 17
         0000001010011001  0000000000011000  9 + 9 = 18

In the program above, instr_1 copies the value of A (9) to instr_3. Instr_2 copies the value of B (7) to instr_3. Instr_3 copies the result (16) from the 'addtable' to C. Instr_4 does nothing repeatedly. The program below shows, after the program has run, from where the data has been copied and to where the data has been copied in italics. You should try to see from where and to where the data was copied by each instruction: instr_1, instr_2, and instr_3.

After Addition Program Has Run

label        address            data           comment

start    0000000000000000  0000000001000000  start 0000000000000100
A        0000000000000001  0000000000001001  9 (A)
B        0000000000000010  0000000000000111  7 (B)
C        0000000000000011  0000000000010110  answer (C)
instr_1  0000000000000100  0000000000000001  from address of A
         0000000000000101  0000000000001100  to instr_3's from addr.
         0000000000000110  0000000011110000  copy to these bits
         0000000000000111  0000000000100100  go to instr_2, rot. 4
instr_2  0000000000001000  0000000000000010  from address of B
         0000000000001001  0000000000001100  to instr_3's from addr.
         0000000000001010  0000000000001111  copy to these bits
         0000000000001011  0000000000110000  go to instr_3, no rot.
instr_3  0000000000001100  0000001010010111  from addtable
         0000000000001101  0000000000000011  to address of C
         0000000000001110  0000000011111111  copy to these bits
         0000000000001111  0000000001000000  go to instr_4, no rot.
instr_4  0000000000010000  0000000000000000  doesn't matter
         0000000000010001  0000000000000000  doesn't matter
         0000000000010010  0000000000000000  copy NO bits
         0000000000010011  0000000001000000  go to this instruction

addtable 0000001000000000  0000000000000000  0 + 0 = 00
         0000001000000001  0000000000000001  0 + 1 = 01
         0000001000000010  0000000000000010  0 + 2 = 02
                                 .
                                 .
                                 .
         0000001010010110  0000000000010101  9 + 6 = 15
         0000001010010111  0000000000010110  9 + 7 = 16
         0000001010011000  0000000000010111  9 + 8 = 17
         0000001010011001  0000000000011000  9 + 9 = 18


Page 31

Page 30 . . . Page 1 . . . Page 32