Microprocessor and Computer Architecture ยท Unit 5
Fixed Point Arithmetic Algorithms
Exam-focused notes for Fixed Point Arithmetic Algorithms (Microprocessor and Computer Architecture, BIT151): what the TU syllabus asks and how it has actually been tested, with 7 solved past questions from this unit.
Fixed Point Arithmetic Algorithms in short
Fixed point arithmetic works on integers stored in registers. Multiplying and dividing signed binary numbers needs special algorithms, because simple shift and add does not handle negative numbers well. This chapter covers Booth's multiplication, restoring division and the hardware for both.
What this unit covers
- Booths multiplication algorithm
- Restoring division algorithm
- Binary division process and step by step execution
- Multiplication and division hardware implementation
Booths multiplication algorithm
2081 ยท 5 marks
Explain the working procedure of Booth Multiplication algorithm. [5]
2080.1 ยท 5 marks
Perform 2's complement multiplication of (15) x (-13) using Booth's Multiplication algorithm. [5]
Show solved answerHide answer
Booth's Multiplication Algorithm: (15) ร (โ13)
Given
- Multiplicand = 15
- Multiplier = โ13
- Method: Booth's algorithm, 2's complement
We need enough bits to represent both operands and their negatives in 2's complement.
- $+15 = 01111$ needs 5 bits, but $+15$ in signed form requires a leading 0, so minimum is 5 bits.
- $-13$: magnitude 13 = $1101$, needs 5-bit signed form $10011$.
5 bits suffices for both.
Binary (5-bit 2's complement):
| Number | Decimal | Binary |
|---|---|---|
| Multiplicand M | +15 | $01111$ |
| Multiplier Q | โ13 | $10011$ |
| โM | โ15 | $10001$ |
Check โ13: $+13 = 01101$, invert $= 10010$, +1 $= 10011$ โ Check โM: $01111$ invert $= 10000$, +1 $= 10001$ โ
Solution
Initialize: A = $00000$, Q = $10011$, Qโโ = 0, count = 5
Rules:
- $Q_0Q_{-1}=10$: A = A โ M, then ARS
- $Q_0Q_{-1}=01$: A = A + M, then ARS
- $00$ or $11$: only ARS
| Step | Operation | A | Q | Qโโ |
|---|---|---|---|---|
| Init | - | 00000 | 10011 | 0 |
| 1 | $Q_0Q_{-1}=10$: A=AโM โ 00000+10001 | 10001 | 10011 | 0 |
| ARS | 11000 | 11001 | 1 | |
| 2 | $Q_0Q_{-1}=11$: ARS only | 11100 | 01100 | 1 |
| 3 | $Q_0Q_{-1}=01$: A=A+M โ 11100+01111=1 01011 | 01011 | 01100 | 1 |
| ARS | 00101 | 10110 | 0 | |
| 4 | $Q_0Q_{-1}=00$: ARS only | 00010 | 11011 | 0 |
| 5 | $Q_0Q_{-1}=10$: A=AโM โ 00010+10001 | 10011 | 11011 | 0 |
| ARS | 11001 | 11101 | 1 |
Carefully redo the ARS steps to be precise (ARS shifts A,Q,Qโโ right, sign bit of A preserved):
Step 1: A=$00000$, subtract M: A=$00000+10001=10001$. ARS of A=$10001$ Q=$10011$ Qโโ=0:
- New A = $11000$, new Q = $11001$, Qโโ = 1 โ
Step 2: $Q_0Q_{-1}=11$ โ ARS only. ARS of A=$11000$ Q=$11001$ Qโโ=1:
- New A = $11100$, new Q = $01100$, Qโโ = 1 โ
Step 3: $Q_0Q_{-1}=01$ โ A=A+M = $11100+01111 = 101011$, keep 5 bits: $01011$. ARS of A=$01011$ Q=$01100$ Qโโ=1:
- New A = $00101$, new Q = $10110$, Qโโ = 0 โ
Step 4: $Q_0Q_{-1}=00$ โ ARS only. ARS of A=$00101$ Q=$10110$ Qโโ=0:
- New A = $00010$, new Q = $11011$, Qโโ = 0 โ
Step 5: $Q_0Q_{-1}=10$ โ A=AโM = $00010+10001 = 10011$. ARS of A=$10011$ Q=$11011$ Qโโ=0:
- New A = $11001$, new Q = $11101$, Qโโ = 1 โ
Final Result
$$\text{Result} = A ,|, Q = 11001,11101$$
Note: the concatenated 10-bit result is $1100111101$.
Convert (10-bit 2's complement): MSB = 1 โ negative. Invert $1100111101 โ 0011000010$, add 1 $โ 0011000011 = 195$.
$$\boxed{15 \times (-13) = -195}$$
Verification: $15 \times 13 = 195$, so $15 \times (-13) = -195$ โ
0 ยท 5 marks
Perform multiplication of (-9) x (-13) using Boothโs Multiplication algorithm. [5]
Restoring division algorithm
2080 ยท 5 marks
Show the step-by-step division process using Restoring Division Algorithm of 194 รท\divรท 10) (AQ= 10100011 by B=1011). [5]
2079 ยท 10 marks
State an algorithm for the restoring division method of fixed point binary division.Show the step-by step division process using restoring division algorithm when 448(0111000000) is divided by 17(10001). Use 5-bit register to represent the numbers.[10]
Show solved answerHide answer
Restoring Division Algorithm (Fixed Point Binary Division)
Algorithm
Registers: A (accumulator/partial remainder), Q (holds dividend, then quotient), M (divisor), Count = number of bits.
- Initialize: A = 0, Q = dividend, M = divisor, Count = n.
- Repeat n times:
- Shift the combined register (A, Q) left by 1 bit.
- A = A โ M (add 2's complement of M).
- If A โฅ 0 (MSB = 0): set Q[0] = 1.
- Else (A < 0, MSB = 1): set Q[0] = 0 and restore A = A + M.
- Decrement Count.
- End: Q = quotient, A = remainder.
Given
- Dividend = 448 =
0111000000(10 bits) - Divisor = 17 =
10001(5 bits) โ M =10001 - 5-bit registers โ n = 5 iterations
- 2's complement of M =
01111
Important note on register sizing
To hold both A and Q for a 10-bit dividend divided by a 5-bit divisor, and to detect the sign of a subtraction of two 5-bit numbers, the accumulator generally needs one extra (sign) bit. Working strictly with 5-bit registers as required, I use A as a 5-bit register and detect "A โฅ 0" via the carry-out of the addition of the 2's complement (carry = 1 means result โฅ 0, no borrow), which is the standard hardware convention.
Loading: A = 00000, Q = 0111000000? Q is only 5 bits. Since the dividend is 10 bits but registers are 5 bits, the standard approach splits the dividend into A and Q:
- A = high 5 bits =
01110 - Q = low 5 bits =
00000
Solution
M = 10001, 2's complement of M = 01111
Initial: A = 01110, Q = 00000
Iteration 1
- Shift left: A =
11100, Q =00000 - A + comp(M):
11100 + 01111 = 101011โ A =01011, carry = 1 โ โฅ 0 โ Q[0] = 1 - A = 01011, Q = 00001
Iteration 2
- Shift left: A =
10110, Q =00010 10110 + 01111 = 100101โ A =00101, carry = 1 โ โฅ 0 โ Q[0] = 1- A = 00101, Q = 00011
Iteration 3
- Shift left: A =
01010, Q =00110 01010 + 01111 = 011001โ A =11001, carry = 0 โ < 0 โ Q[0] = 0, restore- Restore:
11001 + 10001 = 101010โ A =01010 - A = 01010, Q = 00110
Iteration 4
- Shift left: A =
10100, Q =01100 10100 + 01111 = 100011โ A =00011, carry = 1 โ โฅ 0 โ Q[0] = 1- A = 00011, Q = 01101
Iteration 5 (the final required step)
- Shift left: A,Q =
00011 01101โ A =00110, Q =11010 00110 + 01111 = 010101โ A =10101, carry = 0 โ < 0 โ Q[0] = 0, restore- Restore:
10101 + 10001 = 100110โ A =00110 - A = 00110, Q = 11010
Result
- Quotient Q =
11010= 26 - Remainder A =
00110= 6
Verification
$$17 \times 26 + 6 = 442 + 6 = 448 \checkmark$$
Summary Table
| Iter | A (after) | Q (after) | Q[0] |
|---|---|---|---|
| Init | 01110 | 00000 | - |
| 1 | 01011 | 00001 | 1 |
| 2 | 00101 | 00011 | 1 |
| 3 | 01010 | 00110 | 0 |
| 4 | 00011 | 01101 | 1 |
| 5 | 00110 | 11010 | 0 |
Quotient = 26, Remainder = 6.
2080.1 ยท 5 marks
Write a program to perform 8 bit division of data stored in memory location 8050 by data stored in memory location 8051 and store the quotient in memory location 8052 and remainder in 8053 memory location. [5]
Multiplication and division hardware implementation
0 ยท 5 marks
Write a program to perform 8 bit multiplication in 8085 processor. (Assume data and memory yourself). [5]
Make Unit 5 stick
Practice BIT151 with flashcards & quizzes