COA Module 2
COA Module 2
COA Module 2
Computer Organization
and Architecture
6th Edition
Chapter 9
Computer Arithmetic
Arithmetic & Logic Unit
• Handles integers
1 1 1,Carry 1
Example of 2’s Compliment
Find 2’s compliment
1000
0100
111001
101010
100000
Hardware for Addition and Subtraction
Booth’s Algorithm
Q0 Q-1 Result
0 0 Only shift
1 1
0 1 A=A + M ,then shift
1 0 A= A – M , then shift
M =7
Q =3
M=0111
Q=0011
-M=1001
Example of Booth’s Algorithm:7(M)*3(Q)
B. M = 12, Q = 11
C. M = 9, Q=-3
D. M = -13 ( 0011 ) , Q = 6
-M=13 (1101)
A. M = -19 , Q = -20
Division
• More complex than multiplication
• Negative numbers are really bad!
• Based on long division
Division of Unsigned Binary Integers
00001101 Quotient
Divisor 1011 10010011 Dividend
1011
001110
Partial 1011
Remainders
001111
1011
100 Remainder
Flowchart for Restoring Division
Solve using Restoring Division
A. M = 5 , Q = 5 , A=0000 , Q=0010
C. M = 9, Q = 19 , A=00001 , Q =00010
C. M = 9, Q = 19,A=00001,Q=00010.
D. M = 32 , Q = 59,A=011011,Q=000001.
E. M = 17 , Q = 42,A=001000,Q=000010
Booths Recoding / Bit pair recording
STEPS
Solve using Booths Recoding
(1.N)2E-127
32 BIT
64 BIT
(1.N)2E-1023
Steps
• 1. Convert Decimal to Binary
• 2. Normalization
— Rewriting Step 1 into (1.N) form
— Ex: 0 . 0 0 0 1 0 = 0 0 0 0 1 . 0 X 2 -4
• 3.Biasing
— Applying Single Precision (E – 1 2 7) & Double Precision ( E – 1 0 2 3 )
on exponent from Step 2
• 4. Representation in Single (32 bit )and Double Precision (64 bit ) Format
Solved Example
Solve
25.44 SP- 0|100000|1001 0111 0000 1010 0011 110
DP- 0|10000000011|1001 0111 0000 1010 0011 110
a) 7 / -3
b) -7 (Q) / 3 (M)
c) -7 (Q) / -3 (M)
• Dividend negative Remainder –ve
4 phases of FP Arithmetic +/-
• Check for zeros
• Align significands (adjusting exponents)
• Add or subtract significands
• Normalize result
Floating Point Addition
• Overflow
The exponent is too large to be represented in
the Exponent field
• Underflow
The number is too small to be represented in
the Exponent field
Round the result
If the mantissa does not fit in the space
reserved for it, it has to be rounded off.