Booth’s Algorithm
Algorithm
1. Set the Multiplicand and Multiplier binary bits as M and Q, respectively.
2. Initially, we set the Ac and Q-1 registers value to 0.
3. Count represents the number of Multiplier bits (Q), and it is a sequence
counter that is continuously decremented till equal to the number of bits
(n) or reached to 0.
4. A Qn represents the last bit of the Q, and the Q-1 shows the incremented
bit of Qn by 1.
5. On each cycle of the booth algorithm, Qn and Q-1 bits will be checked
on the following parameters as follows:
1. When two bits Qn and Q-1 are 0 0 or 1 1, we simply perform the
Arithmetic Right Shift (ARS) operation to the partial product Acc.
And the bits of Qn and Q-1 is incremented by 1 bit.
2. If the bits of Qn and Q-1 is shows to 0 1, the multiplicand bits (M)
will be added to the Acc (Accumulator register). After that, we
perform the ARS operation to the AC and Q bits, by 1.
3. If the bits of Qn and Q-1 is shows to 1 0, the multiplicand bits (M)
will be subtracted from the Acc. After that, we perform the right shift
operation to the Acc and Q bits by 1.
6. The operation continuously works till we reached n - 1 bit in
the booth algorithm.
7. Results of the Multiplication binary bits will be stored in the
Acc and Q registers.
Arithmetic Shift Right
import [Link]; while (count > 0)
public class Booth {
{ if ((r & 1) == 1)
public int multiply(int n1, int n2) {
{ P += A;
int m = n1; S += m;
int r = n2; }
int A = n1; A <<= 1;
int S = -n1; S <<= 1;
int P = 0; count--;
int count = [Link]; r >>= 1;
}
[Link](count); return P;
}
public static void main(String[] args)
{
Scanner scan = new Scanner([Link]);
Booth b = new Booth();
[Link]("Enter two integer numbers -");
int n1 = [Link]();
int n2 = [Link]();
int result = [Link](n1, n2);
[Link]("\n\nResult : " + n1 + " * " + n2 + " = " + result);
}
}
THANK YOU