CODE
The Hidden Language of Computer Hardware and Software
2nd Edition

Chapter 20. Automating Arithmetic

This chapter describes two circuits that automate addition. The first is the Automated Accumulating Adder in which byte values are stored in memory. The values are added and then the sum is stored in the first memory location with a zero byte.

The second is the Triple Byte Adder. This adds and substracts three-byte values stored in memory where each value is preceded by a one-byte code.

Random-access memory with a capacity of 1,024 bytes is symbolized by a rectangular area at the left of the circuit. By clicking an entry, you can change the value. A text box will appear. Type in the new number in hexadecimal and click the Write button.

You might have to zoom out your web browser to see the entire circuit on a single screen.

Automated Accumulating Adder (pages 294 – 298)

The values in the 1K Memory array at the left are the same as those described in the book. The Counter is outputting an address of 0000h, and the first byte is the A input to the Adder.

To begin the accumulated adder, click the Clock button. The sum of the first byte in memory and 00h will be saved in the Latch.

Click the Clock button again, and the Counter advances to the next memory address of 0001h, and the second byte of memory is accessed. Clicking Clock again will save the new accumulated sum in the latch.

Keep going until the sum from the Latch is written into the first memory address whose contents are 00h.

Your browser does not support the canvas element.

Press the Clear button to reset the Flip-Flops, Counter, and Latch. The Clear button does not affect the contents of the Memory. To restore the Memory to its original values, refresh the browser page.

You might notice that the configuration of the two flip-flops is a little different from that shown in the book. The version in the book is conceptually clearer because the first Clock click advances the Counter while the second generates the Pulse signal.

However, that doesn't work quite right if the Counter begins at address 0000h. In that case, the first Clock click must generate the Pulse signal and the second advances the Counter. For this reasons, the two flip-flop start up in a set state, with the Q outputs equal to 1, and the Clear button is connected to the Preset inputs of the flip-flops.

This same configuration of two flip-flops is used in the next program in this chapter and in the Instruction Decoder in Chapter 23.

Triple-Byte Accumulator (pages 303 – 311)

The values in the 1K Memory array at the left are the same as those described in the book. The Counter is outputting an address of 0000h, and the first byte in memory is accessed. This is an instruction byte. To begin using the triple-byte adder, click the Clock button. That first click saves the byte in the Instruction Latch. The second click advances the Counter and the third click saves that byte in the Low-Byte Latch

The next four clicks of the Clock button advances the address to 0002h and latches the next most significant byte, and then advances the address to 0003 to latche the most-significant byte.

Continue in this way to add and subtract the next several numbers. When the instruction byte is 04h, the three bytes of the result are written into memory. When the instruction byte is 08h, the machine is halted.

Your browser does not support the canvas element.

Press the Clear button to clear the Flip-Flops, Counter, and Latches. The Clear button does not affect the contents of the Memory. To restore the Memory to its original values, refresh the browser page.