Microprocessor Design

Back To Introduction

Back To Introduction

Most microprocessors use the addition function together with the logical NOT operation to subtract one number from another.

In order to use an adder to accomplish subtraction, there must be some kind of transformation or complement that produces the negative of of a number. Mathematicians sometimes call this an

The expression NOT N + 1 works as the negative of N if and only if N + (NOT N + 1) = 0. Here is a list of 4-bit numbers paired with their 2's complements and added together in an expression that equals zero. The method requires ignoring any carry output beyond the most significant bit.

0000 + (1111 + 1) = 0000 + 0000 = 0000 = 0 + 0 0001 + (1110 + 1) = 0001 + 1111 = 0000 = 1 + -1 0010 + (1101 + 1) = 0010 + 1110 = 0000 = 2 + -2 0011 + (1100 + 1) = 0011 + 1101 = 0000 = 3 + -3 0100 + (1011 + 1) = 0100 + 1100 = 0000 = 4 + -4 0101 + (1010 + 1) = 0101 + 1011 = 0000 = 5 + -5 0110 + (1001 + 1) = 0110 + 1010 = 0000 = 6 + -6 0111 + (1000 + 1) = 0111 + 1001 = 0000 = 7 + -7 1000 + (0111 + 1) = 1000 + 1000 = 0000 = -0 + -0 1001 + (0110 + 1) = 1001 + 0111 = 0000 = -7 + 7 1010 + (0101 + 1) = 1010 + 0110 = 0000 = -6 + 6 1011 + (0100 + 1) = 1011 + 0101 = 0000 = -5 + 5 1100 + (0011 + 1) = 1100 + 0100 = 0000 = -4 + 4 1101 + (0010 + 1) = 1101 + 0011 = 0000 = -3 + 3 1110 + (0001 + 1) = 1110 + 0010 = 0000 = -2 + 2 1111 + (0000 + 1) = 1111 + 0001 = 0000 = -1 + 1As suggested by the table above, one could decide that the numbers having a most significant bit equal to 1 are the numbers that we can regard as the negative numbers. The others are positive numbers. This is now a widely-adopted convention that has given rise to a distinction between instructions that perform arithmetic on

Each of the pairs of numbers above adding up to zero are of opposite sign except 0 + 0 = 0 and -0 + -0 = 0. In each case, including these two exceptional ones, the addition works out correctly in signed addition whenever we interpret the most significant bit as the place indicating the minus when it is 1.

This system of signed numbers and signed arithmetic has a cost which has proved to be quite affordable. When instructions work on signed numbers, they have only about half as many magnitudes represented by a digital word. In the 4-bit table above, the numbers range from -7 to +7. (There is no explicitly machine indication of the "+" sign.) The unsigned 4-bit numbers range from 0 to 15. There are 15 magnitudes in signed arithmetic and 16 magnitudes in unsigned arithmetic. The same sort of thing happens in wider words, but the system of recognizing negative numbers by the 1 in the most significant bit is the same.

Notice also that the order of the code bits for the magnitudes in negative numbers is the reverse of the order of bits for the magnitudes of positive numbers. Minus 7 in 4-bit numbers is not 1111 (a 111 = 7 magnitude with a 1 in the most significant bit). It is instead 1001.