Booth's algorithm is a method for multiplying signed binary numbers more efficiently. Let me explain it thoroughly and then work through the example of 3 × (-3).
Background on Booth's Algorithm
Booth's algorithm was invented by Andrew Donald Booth in 1950. It's used to multiply two signed binary numbers in two's complement form. The key advantage is that it can reduce the number of additions/subtractions needed compared to traditional multiplication.
Key Idea
The algorithm looks at the multiplier and recodes it to reduce the number of operations. It recognizes patterns of consecutive 1s in the binary representation and replaces them with a more efficient form.
For example:
- 0111 (7 in binary) = 1000 - 0001 = 8 - 1
- Instead of adding 4 times, we can add once and subtract once
The Recoding Process (Booth Recoding)
We add an implicit 0 bit to the right of the least significant bit of the multiplier. Then, we scan the multiplier from right to left, examining pairs of bits.
The recoding rules are based on transitions:
- 00: no operation (middle of string of 0s)
- 01: beginning of string of 1s (add multiplicand)
- 10: end of string of 1s (subtract multiplicand)
- 11: middle of string of 1s (no operation)
Algorithm Steps
- Recoding Phase: Convert multiplier to Booth form
- Multiplication Phase: For each bit position:
- Add multiplicand, subtract multiplicand, or do nothing based on Booth code
- Shift partial product right by one position
Let me work through the example: 3 × (-3)
Example: 3 × (-3)
Step 1: Represent both numbers in binary (using sufficient bits)
Let's use 8 bits:
Step 2: Recoding the multiplier (-3 = 11111101)
I'll examine the multiplier with an implicit 0 appended on the right, scanning pairs of adjacent bits from right to left. Each pair tells me whether to add, subtract, or skip: a 10 transition signals the end of a run of 1s (subtract), while 01 marks the beginning (add), and 00 or 11 require no operation.
Looking at position 0 where bits are (1, 0), this is a 10 pattern indicating a subtraction. Moving through positions 1-7, I see (0, 1) at position 1 signals an addition, then positions 2-7 all show (1, 1) which are middle bits requiring no action.
Actually, I should simplify this using a 5-bit representation instead. With -3 = 11101 in 5-bit two's complement, the recoding becomes more manageable and clearer to work through. I need to restart with a clearer approach to Booth's algorithm. Let me set up the problem properly with 5-bit two's complement representation for both operands, then systematically apply the recoding rules by examining adjacent bit pairs from right to left in the extended multiplier. The multiplier 11101 becomes 111010 with an implicit 0 appended. Scanning consecutive bit pairs from right to left gives (1,0), (0,1), (1,1), (1,1), (1,1). Each pair determines an operation: 00 or 11 means do nothing, 01 signals the start of a run of 1s and requires adding the multiplicand.
The pair (1,0) at position 0 indicates a run ending, so subtract. At position 1, (0,1) marks a run beginning, so add. Positions 2, 3, and 4 all show (1,1), which means no action—these fall within the continuous run of 1s. This recoding transforms the string of consecutive 1s into a single addition at the top and subtraction at the bottom.
For the multiplication example, I'm using a 5-bit multiplicand A = 00011 (value 3) and multiplier Q = 11101 (value -3). Booth's algorithm requires maintaining several registers: A holds the multiplicand, Q contains the multiplier, P accumulates the partial product starting at zero, and Q_{-1} is an implicit bit tracking the previous multiplier bit. Since we're working with 5-bit values, I need 10 bits total for P to prevent overflow.
Iteration 1 (position 0):
Looking at the last two bits (Q_0, Q_{-1}) = (1, 0), this indicates a subtraction step. I subtract A from P: 00000 - 00011 converts to 00000 + 11101 (two's complement of 00011), giving P = 11101. Then I perform an arithmetic right shift on the combined P:Q register, moving from P=11101, Q=11101, Q_{-1}=0 to P=111101, Q=1110, Q_{-1}=1.
I realize the representation is getting unwieldy with the bit tracking. Let me simplify by using a cleaner 8-bit framework where P and Q each occupy their own space within a unified register, with A = 00011 as the multiplicand and M = 11101 as its two's complement negation.
Starting fresh with 3 × (-3):
Setup:
- Multiplicand A = 00000011 (representing +3)
- Negated form M = 11111101 (representing -3 in 8-bit two's complement)
- Initial P:Q = 00000000:11111101 with Q_{-1} = 0
Examining the multiplier bits:
The multiplier Q = 11111101 gets scanned from right to left, looking at consecutive bit pairs (Q_i, Q_{-1}) to determine whether to add A, subtract M, or do nothing at each iteration.
Position 0 shows (1, 0) which signals a subtraction operation. After subtracting A from P, we get 11111101. The remaining positions (1 through 7) all show (1, 1) patterns, which means no operations occur during those shifts.
Following the arithmetic right shift after the initial subtraction, P becomes 11111110 and Q becomes 11111110 with Q_{-1} set to 1. At position 1, the (1, 1) pattern triggers no operation, so we simply perform another arithmetic right shift: P shifts to 11111111, Q becomes 01111111, and Q_{-1} becomes 0. The algorithm continues with six more shifts through the remaining positions, each producing no arithmetic operations since all subsequent bit pairs are (1, 1). P (partial product): 8 bits
Q (multiplier): 8 bits
Q_{-1}: 1 bit
After each iteration, I shift right and update the state accordingly.
Iteration 1:
- (Q_0, Q_{-1}) = (1, 0) → Subtract
- P := 00000000 - 00000011 = 11111101
- Right shift gives P = 11111110, Q = 11111110, Q_{-1} = 1
Iteration 2:
- (Q_0, Q_{-1}) = (0, 1) → Add
- P := 11111110 + 00000011 = 00000001
- Right shift gives P = 00000000, Q = 11111111, Q_{-1} = 0
Iteration 3:
- (Q_0, Q_{-1}) = (1, 0) → Subtract
- P := 00000000 - 00000011 = 11111101
- Right shift gives P = 11111110, Q = 11111111, Q_{-1} = 1
I'm noticing a repeating cycle here, which suggests an issue with my recoding of -3. Let me verify the two's complement representation again—I need to double-check how -3 encodes in binary before proceeding further. 4, Q_3) = (1, 1) = 11 → No op
i=5: (Q_5, Q_4) = (1, 1) = 11 → No op
i=6: (Q_6, Q_5) = (1, 1) = 11 → No op
i=7: (Q_7, Q_6) = (1, 1) = 11 → No op
So the operations are: subtract at i=0, add at i=1, then subtract at i=2, with no operations for i=3 through i=7. Looking at -3 = 11111101 in binary, I can see a run of consecutive 1s from bit 7 down to bit 2, interrupted by a 0 at bit 1, with a final 1 at bit 0. This structure suggests the recoding pattern follows from how these bit transitions occur—the consecutive 1s create the subtract-add-subtract sequence, followed by the no-ops where bits remain constant. Looking at the bit transitions to identify where runs of 1s begin and end. Starting from the right with the implicit 0 bit, I can see a 10 pattern at positions 0 and -1, which marks the end of a run of 1s. Moving leftward through the pattern, there's a 01 transition at positions 2 and 1, indicating the start of another run. Continuing this analysis across all bit positions reveals the complete structure of the Booth recoding. i=1: (Q[1], Q[0]) = (0, 1) = 01 → add
i=2: (Q[2], Q[1]) = (1, 0) = 10 → subtract
i=3: (Q[3], Q[2]) = (1, 1) = 11 → no-op
i=4: (Q[4], Q[3]) = (1, 1) = 11 → no-op
i=5: (Q[5], Q[4]) = (1, 1) = 11 → no-op
i=6: (Q[6], Q[5]) = (1, 1) = 11 → no-op
i=7: (Q[7], Q[6]) = (1, 1) = 11 → no-op
The recoding gives me a sequence of subtract, add, subtract, followed by no-ops through the remaining bit positions.
Let me double-check this against the expected representation of -3. Since -3 = -4 + 1, I should see a subtract operation at position 2 (contributing -4) and an add at position 0 (contributing +1). The Booth recoded form becomes 0 0 0 0 0 -1 0 1, which matches what I'm getting from the bit pair analysis.
However, my recoding showed subtract at i=0, add at i=1, and subtract at i=2—this doesn't align with what I expect. I need to reconsider how the pair-by-pair scanning works in Booth's algorithm. The key is understanding the iteration process: starting with Q and Q[-1] = 0, at each step i I examine the pair (Q[i], Q[i-1]) to determine whether to add, subtract, or skip before shifting right.
Let me retrace this more carefully. At iteration 0, I check (Q[0], Q[-1]) = (1, 0), which signals a subtraction. After the shift, the register positions change, and at iteration 1 I'm examining the new rightmost two bits. The operations happen sequentially as the register shifts through each cycle.
Actually, the cleaner way to think about this is to track the two rightmost bits of the combined P:Q register at each step. I'll maintain an external bit that captures what was shifted out, then use that along with the current rightmost bit to determine whether to add, subtract, or skip. After each operation, I perform an arithmetic right shift and move to the next iteration.
**Initial state:**
- A = 3 = 00000011
- Q = -3 = 11111101
- P = 0
- Q_out = 0
**Step 1:** The pair (1, 0) signals a subtract operation. After subtracting 3 from P, I get -3, then shift right to get P = 11111110, Q = 11111110, Q_out = 1.
**Step 2:** The pair (0, 1) means add. Adding 3 to the current P gives 1 in the upper bits, and after shifting, the state updates accordingly.
**Step 3:** With the pair (1, 0) appearing again, I subtract 3 from P to get 11111101, shift right, and continue with P = 11111110, Q = 11111111, Q_out = 1.
**Step 4:** The pair (1, 1) indicates no operation is needed.
Shift P:Q right: (11111110 : 11111111) >> 1 = (11111111 : 11111111), Q_out = 1
- P = 11111111
- Q = 11111111
- Q_out = 1
**Steps 5-8:** Each subsequent step encounters the same (1, 1) pair, so no arithmetic operations occur. The arithmetic right shift continues filling in 1s from the left, maintaining P = 11111111, Q = 11111111, Q_out = 1 through the remaining iterations.
**Final result:** P:Q = 11111111 : 11111111 = 1111111111111111 (16 bits), which as a signed 16-bit two's complement value equals -1. However, 3 × (-3) should yield -9, not -1, so there's an error in my calculation. The issue likely stems from how I'm handling the shift operations or the bit widths themselves. I need to reconsider the algorithm more carefully, particularly regarding the width of the partial product P relative to the operands and which bits I'm actually examining.
Let me restart with clearer setup: I'll use 8-bit representations for both the multiplicand A = 3 = 00000011 and multiplier Q = -3 = 11111101, maintaining a 16-bit combined register P:Q where P is the 8-bit accumulator and Q is the 8-bit multiplier, with Q_out tracking the last bit shifted out. Starting from P = 00000000, Q = 11111101, Q_out = 0, I'll check the (Q[0], Q_out) pair at each step to determine whether to add, subtract, or shift.
For iteration 1, since (Q[0], Q_out) = (1, 0) indicates a subtract operation, I compute P - A = 00000000 - 00000011 = 11111101. Then I right-shift the entire P:Q register: the MSB of P (0) becomes the new MSB of Q, Q shifts right to 01111110, and the last bit of Q (1) becomes the new Q_out. After this iteration, P = 11111101, Q = 01111110, Q_out = 1, and the next check will be (Q[0], Q_out) = (0, 1).
In iteration 2, the condition (0, 1) triggers an add operation, so P + A = 11111110 + 00000011 = 00000001. The arithmetic right shift of P:Q produces 00000000 11111111 with Q_out = 0. By iteration 3, I'm checking (Q[0], Q_out) again to determine whether to add or subtract next.
Since (1, 0) indicates a subtract operation, P becomes 11111101 after subtracting A. The shift yields 11111110 11111111 with Q_out = 1. Iteration 4 encounters (1, 1), which is a no-op, so P remains unchanged and the shift produces 11111111 11111111. From iterations 5 through 8, the pattern (1, 1) persists, meaning each cycle just performs the arithmetic right shift without modifying P, keeping the result as 11111111 11111111 with Q_out remaining 1.
Interpreting this as a 16-bit signed value gives -1, but multiplying 3 by -3 should yield -9, which in two's complement is 1111111111110111. There's a discrepancy here—I'm getting -1 instead of the expected -9, so I need to revisit my calculation steps to identify where the error occurred.
Let me reconsider the iteration count. For 8-bit operands, standard Booth's algorithm performs 8 iterations, which appears correct. Tracing through more carefully with the initial setup where P = 00000000, Q = 11111101, Q_out = 0, and A = 00000011, the first iteration checks (Q[0], Q_out) = (1, 0), which signals a subtraction step.
After subtracting A from P in two's complement (00000000 - 00000011 = 11111101), I perform an arithmetic right shift on the combined P:Q register, yielding P = 11111110, Q = 11111110, Q_out = 1. The next check (Q[0], Q_out) = (0, 1) indicates an addition is needed.
Adding A to the new P value (11111110 + 00000011 = 00000001) and shifting right again gives P = 00000000, Q = 11111111, Q_out = 0. This pattern continues through the remaining iterations.
When (Q[0], Q_out) = (1, 0), I subtract A, producing P = 11111101. After shifting, P becomes 11111110 with Q_out = 1. From iteration 4 onward, the condition (Q[0], Q_out) = (1, 1) triggers no operations, just repeated right shifts that propagate the sign bit through P while Q remains 11111111. By iteration 8, P stabilizes at 11111111 as the algorithm completes its cycles.
The result P:Q = 1111111111111111 represents -1, which doesn't match the expected product. I need to reconsider the problem setup—specifically whether we're computing 3 × (-3) = -9, and which operand serves as the multiplicand versus the multiplier in Booth's algorithm.
Let me try reversing the operands: A = -3 and Q = 3. Starting with P = 0, Q = 00000011, and Q_out = 0, the first check of (Q[0], Q_out) = (1, 0) signals a subtraction. After subtracting A from P, I get 3, then shift the combined P:Q register right by one bit.
In iteration 2, the pattern (1, 1) means no operation occurs, so P stays at 00000001 while the shift continues. By iteration 3, the bit pattern (0, 1) triggers an addition of A back to P, giving -3, followed by another rightward shift of the P:Q pair.
Moving through iterations 4 and beyond, the no-op cases keep repeating as (Q[0], Q_out) stays at (0, 0), with P remaining at 11111110 and then 11111111 as the bits continue shifting right. The algorithm doesn't seem to be converging toward the expected result, which suggests there might be an issue with how the arithmetic right shift is being applied—particularly whether the sign bit is being properly extended when shifting a negative number.
Let me reconsider the shift mechanics. When P is negative (MSB = 1), the arithmetic right shift should fill in 1s from the left, not 0s. In iteration 3, when shifting P:Q = 11111101 11000000 right by 1, P should become 11111110 with the sign bit preserved, and Q should receive P's old LSB. This seems correct, but I need to verify whether the sign extension is happening consistently throughout all iterations, since that could explain why the result isn't converging properly. When shifting right, P[0] moves into Q[7] while the sign bit extends into P[7], and Q[0] exits the register. After all iterations, the product sits in P:Q, though I might only need to read P depending on the result width.
Let me reconsider the algorithm structure. Perhaps the issue is with how I'm setting up the bit widths or interpreting where the final result lives. I should test this with a concrete example—computing 3 × 2 using Booth's algorithm to verify my understanding of the process.
Starting with A = 3 = 00000011 and Q = 2 = 00000010, Q_out = 0. In the first iteration, (Q[0], Q_out) = (0, 0) triggers a no-op, so I just shift right: the pair becomes 00000000 00000001 with Q_out = 0. The second iteration sees (Q[0], Q_out) = (1, 0), which means subtract—P becomes 11111101 after subtracting A. After shifting, P = 11111110 and Q = 10000000. From iteration 3 onward, (Q[0], Q_out) = (0, 1) calls for addition, so P = 11111110 + 00000011 = 00000001. Shifting gives P = 00000000 and Q = 11000000. The remaining iterations with (Q[0], Q_out) = (0, 0) just perform shifts until completion.
After six more right shifts from P:Q = 00000000 11000000, the final result is P:Q = 00000000 00000110 = 6, confirming 3 × 2 = 6. The product occupies both registers as a 16-bit value, so I need to read the combined P:Q result rather than P alone. Now I should verify the algorithm works for 3 × (-3), being careful about how negative multipliers are represented and processed. 9, not -1! Let me trace through iteration 4 again more carefully.
After iteration 3, I have P = 11111110, Q = 11111111, Q_out = 1. Since (Q[0], Q_out) = (1, 1), this is a no-op, so P stays the same. When I shift right, the MSB of P remains 1 (arithmetic shift for negative numbers), giving P = 11111111. The LSB of P shifts into Q, and Q shifts right as well.
After the shift: P = 11111111, Q = 11111111, Q_out = 1.
I'm getting the same result, so let me try working through this with smaller numbers instead. Using 5-bit values might make the pattern clearer: A = 3 = 00011, Q = -3 = 11101 in two's complement, Q_out = 0 initially, and I'll perform 5 iterations.
Starting with P = 00000, the first step checks (Q[0], Q_out) = (1, 0), which signals a subtract operation. After subtracting A from P and performing the arithmetic right shift on the P:Q pair, I get P = 11110, Q = 11110, Q_out = 1. In the next iteration, (Q[0], Q_out) = (0, 1) indicates an add, so I add A back to P.
Computing -2 + 3 gives 1, so P becomes 00001. After shifting right again, P = 00000 and Q = 11111, with Q_out = 0.
In iteration 3, the pair (Q[0], Q_out) = (1, 0) triggers a subtraction: P - A = 00000 - 00011 = 11101. Following the rightward shift, P = 11110 and Q = 11111, Q_out = 1. On the fourth iteration, since (Q[0], Q_out) = (1, 1), no operation occurs and P remains 11110 before shifting.
Continuing the shift operation: P becomes 11111 and Q becomes 01111 with Q_out = 1. The fifth iteration again encounters (Q[0], Q_out) = (1, 1), so another no-op shift follows, leaving P at 11111 while Q shifts to 10111. The final 10-bit result is 1111110111.
Converting to decimal as a signed value: the set bits are at positions 9, 8, 7, 6, 5, 2, 1, and 0, with only bit 3 unset. Using two's complement, this equals -512 + 503 = -9, confirming the result.
The 10-bit product from the 5-bit operands is working correctly. Let me trace through the 8-bit case to find where the discrepancy occurs. Starting with A = 3 and Q = -3, when the first iteration detects the (1, 0) pattern, I subtract A from P, giving -3. After the arithmetic right shift, P becomes 11111110 and Q shifts to 11111110 with Q_out set to 1.
In iteration 2, the (0, 1) pattern triggers an add operation. Adding 3 to -2 yields 1, which after shifting produces P = 00000000 and Q = 11111111. The third iteration subtracts again when detecting (1, 0), resulting in P = 11111110 and Q = 11111111. The final iteration encounters (1, 1), which requires no arithmetic operation—just the shift that sets P = 11111111 and Q = 0.
From iteration 4 onward, the algorithm enters a pattern where P remains all 1s while Q continues shifting with P[0] feeding into Q[7]. Each subsequent cycle maintains the (1, 1) condition, causing repeated no-op shifts that progressively fill Q with 1s from the MSB downward. By iteration 8, this shifting process completes, leaving P = 11111111 and Q approaching its final state.
The final 16-bit result is 1111111111110111. Converting to decimal in two's complement: the leading 1 indicates a negative number, and calculating the magnitude shows this equals -1.
Actually, let me recalculate more carefully. All bits are set except bit 3, which means I have 2^15 - 1 = 32767 in positive bits, minus 8 for the missing bit 3, giving 32759. With the sign bit, that's -32768 + 32759 = -9.
So the arithmetic division result is -9, confirming the 8-bit calculation was correct.
Now I need to think through how to explain this clearly. Let me verify once more by working through the Baugh-Wooley algorithm step by step with the 8-bit operands: multiplicand A = +3 (00000011) and multiplier Q = -3 (11111101 in two's complement). Starting with P = 0 and Q_out = 0, I'll iterate through each bit position, checking the (Q[0], Q_out) pair to determine whether to add or subtract at each step. I need to trace through each iteration more carefully. Let me work through the Booth pairs systematically by examining Q and Q_out at each step, then verify the result after iteration 2 to ensure the arithmetic right shift is working correctly on the combined PQ register. When shifting right by 1 bit across the 16-bit P:Q pair, the sign bit fills P[7], P[0] moves into Q[7], and Q[0] is output. With P = 00000001, the sign bit is 0, so new P becomes 00000000. For Q = 11111110, shifting right gives 01111111, then placing P[0] (which is 1) into the new Q[7] yields 11111111.
For iteration 8 starting with P = 11111111 and Q = 11101111: since Q[0] = 1 and Q_out = 1, no operation occurs. The right shift produces new P = 11111111 (sign bit 1 with P[7:1]), new Q = 11110111 (P[0] = 1 into Q[7:1] = 1110111), and Q_out = 1. This gives P:Q = 11111111 11110111, which converts to a negative value in two's complement.
Computing the decimal: the MSB contributes -32768, and the remaining bits sum to 32759, yielding -9. This confirms the result is correct.</think>
# Booth's Algorithm for Signed Binary Multiplication
## Algorithm Overview
Booth's algorithm efficiently multiplies two signed binary numbers by recognizing that a sequence of consecutive 1s in binary can be replaced with a subtraction followed by an addition. This reduces the number of operations needed.
**Key Insight:** `0111 (7) = 1000 - 0001 (8 - 1)` - one addition and one subtraction instead of four additions.
---
## The Algorithm
### Setup
- **A**: multiplicand register
- **Q**: multiplier register
- **P**: partial product (initially 0)
- **Q₋₁**: implicit bit tracking the last bit shifted out (initially 0)
### Recoding Rules (Booth Pairs)
At each iteration, examine the two rightmost bits `(Q[0], Q₋₁)`:
| Pair | Operation |
|------|-----------|
| 00 | No operation |
| 01 | **Add** multiplicand (beginning of 1-run) |
| 10 | **Subtract** multiplicand (end of 1-run) |
| 11 | No operation (middle of 1-run) |
### Steps
1. Check the bit pair and perform operation
2. Arithmetic right shift P:Q by 1 bit
3. Repeat for n iterations (n = bit width)
---
## Worked Example: 3 × (-3)
### Setup (8-bit operands)
Multiplicand: A = 3 = 00000011
Multiplier: Q = -3 = 11111101 (two's complement)
Initial P: 00000000
Q₋₁: 0
### Booth Recoding of -3 (11111101)
Looking at bit transitions:
- **Position 0**: (1,0) = 10 → **Subtract**
- **Position 1**: (0,1) = 01 → **Add**
- **Positions 2-7**: (1,1) = 11 → **No-op** (sign extension continues)
---
### Step-by-Step Execution
**Iteration 1:** (Q[0], Q₋₁) = (1, 0) = "10" → SUBTRACT
P = 00000000 - 00000011 = 11111101 (-3)
Shift P:Q right: 11111110 | 11111110, Q₋₁ = 1
**Iteration 2:** (Q[0], Q₋₁) = (0, 1) = "01" → ADD
P = 11111110 + 00000011 = 00000001 (-2 + 3 = 1)
Shift P:Q right: 00000000 | 11111111, Q₋₁ = 0
**Iteration 3:** (Q[0], Q₋₁) = (1, 0) = "10" → SUBTRACT
P = 00000000 - 00000011 = 11111101
Shift P:Q right: 11111110 | 11111111, Q₋₁ = 1
**Iterations 4-8:** (Q[0], Q₋₁) = (1, 1) = "11" → NO-OP (just shift)
Iteration 4: 11111111 | 01111111, Q₋₁ = 1
Iteration 5: 11111111 | 10111111, Q₋₁ = 1
Iteration 6: 11111111 | 11011111, Q₋₁ = 1
Iteration 7: 11111111 | 11101111, Q₋₁ = 1
Iteration 8: 11111111 | 11110111, Q₋₁ = 1
---
## Final Result
P:Q = 1111111111110111 (16-bit result)
Converting to decimal:
= -2¹⁵ + (2¹⁴ + 2¹³ + ... + 2⁴ + 2² + 2¹ + 2⁰)
= -32768 + 32759
= -9 ✓
**3 × (-3) = -9** ✓
---
## Why Booth's Algorithm is Efficient
For multiplier `11111101 (-3)`:
- **Traditional method**: Would require 6 additions (one for each 1-bit)
- **Booth's method**: 1 subtraction + 1 addition + shifts
This advantage scales with sequences of consecutive 1s or 0s in the multiplier.