5 Fixed Point Arithmetic Algorithms

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.

Fixed Point Arithmetic Algorithms: notes

Booths multiplication algorithm

Booth's algorithm multiplies two signed numbers in 2's complement form. It also saves work. A run of 1s in the multiplier needs only one subtraction and one addition, not many additions.

Registers used:

  • BR: the multiplicand.
  • QR: the multiplier.
  • AC: the accumulator, starts at 0.
  • $Q_{n+1}$: one extra flip-flop, starts at 0. It holds the bit shifted out of QR.
  • SC: a counter set to the number of bits n.

The rule looks at the pair $Q_n Q_{n+1}$ (the last bit of QR and the extra flip-flop):

$Q_n Q_{n+1}$Action
10Start of a run of 1s: $AC \leftarrow AC - BR$
01End of a run of 1s: $AC \leftarrow AC + BR$
00 or 11Do nothing

After this action, do an arithmetic shift right on AC, QR and $Q_{n+1}$. The sign bit of AC is copied back into itself. Decrease SC, and repeat until SC is 0. The product is in AC and QR together (2n bits).

Example 1: $15 \times (-13)$ with 5 bits. BR = 01111 (15). QR = 10011 ($-13$). $-BR$ = 10001.

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]

Booth's algorithm is an efficient algorithm for multiplying two signed binary numbers represented in 2's complement form. It handles both positive and negative numbers uniformly and reduces the number of additions/subtractions required. --- Component Description ------------------------ A Accumul...

Open this answer on its own page โ†’

2080.1 ยท 5 marks

Perform 2's complement multiplication of (15) x (-13) using Booth's Multiplication algorithm. [5]

Show solved 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):

NumberDecimalBinary
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
StepOperationAQQโ‚‹โ‚
Init-00000100110
1$Q_0Q_{-1}=10$: A=Aโˆ’M โ†’ 00000+1000110001100110
ARS11000110011
2$Q_0Q_{-1}=11$: ARS only11100011001
3$Q_0Q_{-1}=01$: A=A+M โ†’ 11100+01111=1 0101101011011001
ARS00101101100
4$Q_0Q_{-1}=00$: ARS only00010110110
5$Q_0Q_{-1}=10$: A=Aโˆ’M โ†’ 00010+1000110011110110
ARS11001111011

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$ โœ“

Open this answer on its own page โ†’

0 ยท 5 marks

Perform multiplication of (-9) x (-13) using Boothโ€™s Multiplication algorithm. [5]

  • Multiplicand $M = -9$ - Multiplier $Q = -13$ - Expected product $= (-9)(-13) = +117$ $+9 = 01001 \Rightarrow -9 = 10111$ (2's complement) $+13 = 01101 \Rightarrow -13 = 10011$ (2's complement) So: - $M = 10111$ - $-M = 01001$ - $Q = 10011$ - $Q{-1} = 0$ - $A = 00000$ $Q0$ $Q{-1}$ Operation ----...
Open this answer on its own page โ†’

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]

  • Combined register AQ = 10100011 (8 bits) - Divisor B = 1011 (4 bits) = 11 in decimal - Split: A (accumulator) = 1010, Q (dividend/quotient) = 0011 Interpretation check: The title says "194 รท 10". Note that $101000112 = 163$, not 194, and $10112 = 11$, not 10. The binary values given (AQ = 10100...
Open this answer on its own page โ†’

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 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.

  1. Initialize: A = 0, Q = dividend, M = divisor, Count = n.
  2. 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.
  3. 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

IterA (after)Q (after)Q[0]
Init0111000000-
101011000011
200101000111
301010001100
400011011011
500110110100

Quotient = 26, Remainder = 6.

Open this answer on its own page โ†’

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]

  • Dividend: stored at memory location 8050H - Divisor: stored at memory location 8051H - Quotient: store at memory location 8052H - Remainder: store at memory location 8053H --- The 8085 microprocessor does not have a direct division instruction. Division is performed by repeated subtraction meth...
Open this answer on its own page โ†’

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]

The problem says "Assume data and memory yourself," so I choose: Item Value Memory Location ------------------------------ Multiplicand 05H 2200H Multiplier 04H 2201H Result low byte (computed) 2202H Result high byte (computed) 2203H No mandatory numeric inputs are missing; all values are self-as...

Open this answer on its own page โ†’