The following program multiplies two numbers together. It calculates C = A X B where A is 9, B is 7 and C is the answer (63). It is the same as the addition program except that it uses a multiplication table rather than an addition table.

Multiplication 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  0000010000000000  from multiply table
         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

multiply 0000010000000000  0000000000000000  0 X 0 = 00
         0000010000000001  0000000000000000  0 X 1 = 00
         0000010000000010  0000000000000000  0 X 2 = 00
                                 .
                                 .
                                 .
         0000010010010110  0000000001010100  9 X 6 = 54
         0000010010010111  0000000001100011  9 X 7 = 63
         0000010010011000  0000000001110010  9 X 8 = 72
         0000010010011001  0000000010000001  9 X 9 = 81

Notice that one can save a lot of work by salvaging (copying) instructions from a program one has already written for use in a new, similar program. Tables can often be salvaged as well.


Page 32

Page 31 . . . Page 1 . . . Page 33