Professional Documents
Culture Documents
4/19/2004
Section 10
Page 10-1
Arithmetic operations
Data types
Computer Arithmetic
representation
complement representation
Floating-point binary
Binary-coded decimal (BCD)
Slides with white background courtesy of Mano text for this class
1
Hardware
Description
z
z
z
z
z
AS
BS
AS & A
AVF
E
Flowchart
Sign of A
Sign of B
Accumulator
Overflow bit for A + B
Output carry for parallel adder
4/19/2004
Page 10-2
Algorithm
Multiply Signed-Magnitude
z
z
Hardware
Description
z
z
z
z
z
z
Flowchart
Q
multiplier
B
multiplicand
A
0
SC
number of bits in multiplier
E
overflow bit for A
Do SC times
If low-order bit of Q is 1
10
A+B
Product is in AQ
11
12
4/19/2004
Example: 23 x 19 = 437
Page 10-3
Booth algorithm
QR
multiplier
Qn
least significant bit of QR
Qn+1
previous least significant bit of QR
BR
multiplicand
AC
0
SC
number of bits in multiplier
13
Algorithm
z
14
Hardware
Do SC + 1 times
QnQn+1 = 10
QnQn+1 = 01
AC
AC
AC + BR + 1
AC + BR
15
Flowchart
17
16
18
4/19/2004
Array Multiplier
z
z
z
z
Page 10-4
Combination circuit
Product generated in one microoperation
Requires large number of gates
Became feasible after integrated circuits
developed
Needed for j multiplier and k multiplicand bits
j x k AND gates
j 1 k-bit adders to produce product of j + k bits
19
20
21
Example: 448 17 = 26 r 6
22
Algorithm
Initially,
AQ dividend
B
divisor
At end of operation,
Q
quotient
A
remainder
DVF divide overflow
23
24
4/19/2004
Floating-Point Registers
Page 10-5
Biased Exponent
z
Example
Sign
Mantissa
Exponent
25
to deal with
26
AC AC + BR
or
AC AC BR
27
Floating-Point Multiply
z
z
z
z
28
29
30
4/19/2004
Floating-Point Division
z
z
z
z
z
Page 10-6
31
32
33
34
of 1s from 23 to 21: 24 21 = 16 2 = 14
M: M x 14 = M x 24 M x 21
Product obtained by M 4 times to the left and
subtracting M shifted left once
Multiplicand
35
36
4/19/2004
BCD Adder
z
z
z
Page 10-7
37
Examples
z
9
7
16
1001
0111
1 0000
0110
0110
38
BCD Subtraction
9 1001
9 1001
18 1 0010
0110
1000
6
4
10
0110
0100
1010
0110
1 0000
Complement bits
Add 1010 (decimal 10) and discard carry
39
Examples
z
0111 decimal 7
1000 complement
+1010 decimal 10
1 0010 decimal 2
40
41
42
4/19/2004
43
Slow
Page 10-8
Fast
44
45
Very slow
46
47
0456
0456
+ 0456
1368
0136 8
0456
+ 0456
1048
0104 88
+ 0456
0560
0056 088
0005 6088
shift
shift
shift
shift
48
4/19/2004
49
Page 10-9