Article Directory
AD Booth proposes an algorithm: multiplying two numbers is represented by complement, their sign bit and value participate in the process of multiplication together, and the result of the multiplication represented by complement is directly obtained, and positive and negative numbers are treated equally. This algorithm is called Booth's algorithm.
All discussed below are numbers with sign bits.
One's complement multiplication
The rules for complement multiplication are as follows:
- The lowest bit of the multiplier adds an auxiliary bit y n+1 = 0, and the subscript n starts from 0 instead of 1.
- Judge the value of y n-i y n-i+1 and decide whether it is "+X" or "-X", or just shift one bit to the right to get a partial product.
- Repeat the second step until the highest bit is seen in the operation (y 1 -y 0 )* X, but without shifting, the result is [X*Y] complement
the n-i | the n-i + 1 | |
---|---|---|
1 | 0 | +[-X] complement |
0 | 1 | +[X] complement |
0 | 0 | Shift right |
1 | 1 | Shift right |
Here is an example:
- Knowing that X=13, Y=-10, use Booth’s multiplication to find the complement of [X*Y]
: get [X] complement =01101, [Y] complement =10110, [-X] complement =10011, suppose one P is initialized to all 0s, and the number of bits is two sign bits and four significant bits.
Therefore, the algorithm process of Booth's algorithm is a loop of "judgment → addition and subtraction → right shift" for n+1 times, and the number of right shifts is n times.
Two's complement two-digit multiplication
The operation process of two-complement two-bit multiplication is similar to Booth's algorithm. It distinguishes knowledge to judge three digits in one group, addition and subtraction operation +[X] complement , +2[X] complement , +2[-X] complement , +[-X] complement, a total of four cases. Each time the partial product and multiplier are generally shifted two bits to the right.
- Set multiplier [Y] complement = y 0 y 1 …y n
1. When n is an even number, the total number of cycles in the multiplication operation is n/2+1. The last time does not shift right, because the last time is only the operation on the sign bit.
2. When n is an odd number, the total number of cycles in the multiplication process is (n+1)/2. Shift right one bit last time, because the last time is the operation of the sign bit and the highest value bit, the original acid of the sign bit does not need to be shifted right.
the n-i-1 | the n-i | the n-i + 1 | Addition and subtraction rules |
---|---|---|---|
0 | 0 | 0 | 0 |
0 | 0 | 1 | +[X] complement |
0 | 1 | 0 | +[X] complement |
0 | 1 | 1 | +2[X] complement |
1 | 0 | 0 | +2[-X] complement |
1 | 0 | 1 | +[-X] complement |
1 | 1 | 0 | +[-X] complement |
1 | 1 | 1 | 0 |
Here is an example:
Given that [X] complement = 00011, [Y] complement = 11010, then [-X] complement = 11101. Calculate [XY]'s complement with two's complement two-digit multiplication .
Solution: The digits of P are three sign bits and four significant bits.