The following program adds two two-digit numbers, A (99) and B (87), together for a result of C (186). First, it adds the right digits together (9+7) for a result of 16. 16 is 6 with a carry. Then, the carry, 1, is added to 9 and 8 for a result of 18. That makes the entire answer 186. Adding 1+9+8 together requires an add with carry, so we need a table with carry of 1 or 0 as below. For this table, there are 200 possibilities. There are 2 values of carry (0 or 1), 10 values of one input (0-9), and 10 values of another input (0-9) for 2 X 10 X 10 = 200 possibilities. Notice the carry, '+0' and '+1,' in the upper left of the tables below. The two tables below are two halves of the entire table.
Add with Carry Table
+0 0 1 2 3 4 5 6 7 8 9 0 0 1 2 3 4 5 6 7 8 9 1 1 2 3 4 5 6 7 8 9 10 2 2 3 4 5 6 7 8 9 10 11 3 3 4 5 6 7 8 9 10 11 12 4 4 5 6 7 8 9 10 11 12 13 5 5 6 7 8 9 10 11 12 13 14 6 6 7 8 9 10 11 12 13 14 15 7 7 8 9 10 11 12 13 14 15 16 8 8 9 10 11 12 13 14 15 16 17 9 9 10 11 12 13 14 15 16 17 18 +1 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 11 2 3 4 5 6 7 8 9 10 11 12 3 4 5 6 7 8 9 10 11 12 13 4 5 6 7 8 9 10 11 12 13 14 5 6 7 8 9 10 11 12 13 14 15 6 7 8 9 10 11 12 13 14 15 16 7 8 9 10 11 12 13 14 15 16 17 8 9 10 11 12 13 14 15 16 17 18 9 10 11 12 13 14 15 16 17 18 19
The 'add with carry' table for the program is shown below. Notice that the carry is represented with only 1 bit because carry can only have two values, 0 or 1. A normal digit requires 4 bits for the 10 possibilities, 0-9.
Add with Carry Table Listing
label address data comment addtable 0000001000000000 0000000000000000 0 + 0 + 0 = 00 0000001000000001 0000000000000001 0 + 0 + 1 = 01 0000001000000010 0000000000000010 0 + 0 + 2 = 02 . . . 0000001010010110 0000000000010101 0 + 9 + 6 = 15 0000001010010111 0000000000010110 0 + 9 + 7 = 16 0000001010011000 0000000000010111 0 + 9 + 8 = 17 0000001010011001 0000000000011000 0 + 9 + 9 = 18 0000001100000000 0000000000000001 1 + 0 + 0 = 01 0000001100000001 0000000000000010 1 + 0 + 1 = 02 0000001100000010 0000000000000011 1 + 0 + 2 = 03 . . . 0000001110010110 0000000000010110 1 + 9 + 6 = 16 0000001110010111 0000000000010111 1 + 9 + 7 = 17 0000001110011000 0000000000011000 1 + 9 + 8 = 18 0000001110011001 0000000000011001 1 + 9 + 9 = 19
Page 33
Page 32 . . . Page 1 . . . Page 34