FALLSEM2019-20 EEE4024 TH VL2019201001067 Reference Material I 02-Aug-2019 Computer Arithmetic
FALLSEM2019-20 EEE4024 TH VL2019201001067 Reference Material I 02-Aug-2019 Computer Arithmetic
Marimuthu R
Addition/Subtraction Using Sign–Magnitude
Complementer
Algorithm - Addition
➢Magnitude & sign bit of Augend are loaded in register “A” and “As” respectively.
➢Magnitude & sign bit of Addend are loaded in register “B” and “Bs” respectively.
➢Compare the sign bit by performing EXOR. i.e As ⊕ Bs
➢If the sign bit is zero, perform addition (A+B) and transfer carry (E) bit to
overflow (AVF). Register “A” and sign bit “As” holds the result.
➢If the sign bit is one, take 2’s complement of B and add with A. i.e (A+~B+1)
and clear overflow bit.
➢When you get carry from 2’s complement:
➢ ignore the carry and the answer is positive. (A>=B)
➢ Clear As bit and the register A holds the result.
(a) 23 x 19
(b) 120 x 24
(c) -22 x 18
(d) -15 x -22
Booth Algorithm
• Applicable for both +ve and –ve numbers (2’s complement).
• Recoded the multiplier bits.
• It helps to reduce the number of additions in the multiplier.
(Approximately n/2 times) where n is number of bits in the multiplier.
• It operates on the fact that strings of 0’s in the multiplier require no
addition but arithmetic shifting is required.
• String of 1’s in the multiplier from bit weight 2i+n-1 to 2i can be treated
as 2i+n – 2i (For +ve numbers).
• Ex, 01111 (15 in decimal) is recoded as 24 – 20 = 15.
• For negative numbers, the recoding formula is -2i
Booth Algorithm
Booth Recoding: It is based on LSB of multiplier bit (Qn) and an
imaginary bit (Qn+1) and it’s initially assumed as zero. (QnQn+1)
56 x 34
-178 x 88
-12 x -24
Modified Booth Recoding
Also called “Bit Pair Recoding”
Procedure:
➢Group the Booth recoded multiplier bits in pairs.
➢Fast multiplication algorithm when compare to Booth.
➢ Applicable for even number of bits.
Ex: (Worst Case Booth Multiplier)
0 1 0 1 0 1 0 1 0 1
+1 -1 +1 -1 +1 -1 +1 -1 +1 -1
Modified Booth Recoding
Modified Booth Recoding
Modified Booth Algorithm
• 12 x -5
• 13 x -6
• 27 x 17
Robertson Multiplier
➢Applicable for signed 2’s complement numbers.
Algorithm:
1. Initialize register “A” =0; Count = 0; Sign Bit (S) = 0 and store multiplicand in
“M” & multiplier in register “Q”.
2. Check Q[0] value. Q[0] = 1, add “A” with “M” else add “A” with zero.
3. Update S using the following expression: (M[n] & Q[0]) | Sold.
4. Perform right shift of (Sign Bit, A & Q) and increment the count. Go to step 2
until count value not equal to n. (n is length of the multiplier).
When count value is equal to n, perform the following
5. Check Q[0] value. Q[0] = 1, Subtract “A” with “M” else subtract “A” with zero.
6. Update S using the expression M[n] XOR Q[0].
7. Perform right shift of (Sign Bit, A & Q) and increment the count. Final product
in A & Q.
Robertson Multiplier
Ex:
-6 x -3
-12 x 8
Restoring Algorithm
Applicable for +ve numbers only.
Algorithm: Do the following “n” times
Co = AB + (A^B)C-1
ALU
Steps:
➢Compare the magnitude of two exponents and make suitable
alignments to the number with the smaller magnitude of exponent.
➢Perform the addition/Subtraction.
➢Perform normalization by shifting the resulting mantissa and
adjusting the resulting exponent.
EX:
1.1100 x 24 and 1.100 x 22
Floating Point Addition/Subtraction
Division:
➢Subtract the exponents
➢Divide the mantissas and determine the sign of the result.
➢Normalize the resulting value, if necessary.
Floating Point Multiplication & Division
0.621 x 0.721
-0.3 x 500.25
91.34375/0.14453125