This chapter expands on the adders shown in Chapter 14 to implement subtraction.
This first circuit is very similar to the eight-bit adder shown at the end of Chapter 14. However, notice that the plus sign to the left in now implemented in a button. You can toggle that button between addition and subtraction.
When you choose to subtract the second number from the first, an array of XOR gates inverts the values of the second row of buttons (which calculates the ones’ complement), and sets Carry In at the right to 1, which effectively forms the two’s complement. The two numbers are then added.
If an addition results in a value greater than 255, or a subtraction results in a value less than zero, this is indicated by the Overflow output, and the result is invalid. When such an adder is cascaded with other adders for a larger value, that overflow might be treated as a Carry or a Borrow.
The following adder is dedicated to adding a pair of eight-bit two’s complement numbers that range from 80h (decimal –128) through 7Fh (decimal 127). The hexadecimal and decimal equivalents of the values you choose are shown at the right.
If one value is positive and the other negative, the result is always valid as indicated by an Overflow value of 0. But if the two values are positive and the sum is greater than 127, or the two values are negative and the sum is less than –128, an Overflow value of 1 indicates a problem.