Vous êtes sur la page 1sur 20

ARITHMETRIC FOR

COMPUTER

MULTIPLICATION
TEAM: VO HOANG CHUONG
TEAM MEMBERS
1. Vo Hoang Chuong ( Leader )
2. Le Quang Dao
3. Le Duc Minh Tuan
4. Ho Ba Trung
5. Tran Le Quoc
Let’s review the multiplication of decimal
numbers to remind us of the steps of
multiplication and the names of the operands.

In a multiplication, the first operand is called the


multiplicand and the second the multiplier.
The final result is called the product.
1000
0000

0000
1000

1001000
We restricted the decimal digits to 0 and 1. With only
two choices, each step of the multiplication is simple:

1. Just place a copy of the multiplicand


(1*multiplicand) in the proper place if the multiplier
digit is a 1
2. Place 0 (0 * multiplicand) in the proper place if the
digit is 0.
In fact, if we ignore the sign bits, the length
of the multiplication of an n-bit multiplicand
and an m-bit multiplier is a product that is n +
m bits long. That is, n + m bits are required
to represent all possible products

For example : It required 8 bits to represent


all possible products of the multiplication of an
4- bit multiplicand and an 4- bit multiplier
MULTIPLICATION
ALGORITHM
0010 x 0011

Multiplier Multiplicand Product


0011 0000 0010 0000 0000
0001 0000 0100 0000 0010
0000 0000 1000 0000 0110
0000 0001 0000 0000 0110
0000 0010 0000 0000 0110 Done
MULTIPLICATION
ALGORITHM
MULTIPLICATION
ALGORITHM

0010 x 0011
MULTIPLICATION
ALGORITHM
Example of unsigned Multiplication

Calculate: 3 x 8
Iteration Step Multiplier Multiplicand Product
0 Initial values 1000 00000011 00000000
1 1: 0 ⟹ No operation 1000 00000011 00000000
2: Shift left Multiplicand 1000 00000110 00000000
3: Shift right Multiplier 0100 00000110 00000000
2 1: 0 ⟹ No operation 0100 00000110 00000000
2: Shift left Multiplicand 0100 00001100 00000000
3: Shift right Multiplier 0010 00001100 00000000
3 1: 0 ⟹ No operation 0010 00001100 00000000
2: Shift left Multiplicand 0010 00011000 00000000
3: Shift right Multiplier 0001 00011000 00000000
4 1a: 1 ⟹ Prod = Prod + Mcand 0001 00011000 00011000
2: Shift left Multiplicand 0000 00110000 00011000
3: Shift right Multiplier 0000 00110000 00011000
SIGNED MULTIPLICATION
The signed multiplication has 2 cases:
1. Both operands have the same sign => Positive product
2. The operands have opposite sign => Negative product
How to perform the signed multiplication:
1. Convert the negative operand(s) to positive operand(s)
2. Multiply the operands like unsigned case.
3. Negate the product if there is the sign disagreement.
Example of signed Multiplication

Calculate: 3 x -8
Iteration Step Multiplier Multiplicand Product
0 Initial values 11000 00000011 0000000000
1 Convert to positive number 01000 00000011 0000000000
2 1: 0 ⟹ No operation 01000 00000011 0000000000
2: Shift left Multiplicand 01000 00000110 0000000000
3: Shift right Multiplier 00100 00000110 0000000000
3 1: 0 ⟹ No operation 00100 00000110 0000000000
2: Shift left Multiplicand 00100 00001100 0000000000
3: Shift right Multiplier 00010 00001100 0000000000
4 1: 0 ⟹ No operation 00010 00001100 0000000000
2: Shift left Multiplicand 00010 00011000 0000000000
3: Shift right Multiplier 00001 00011000 0000000000
5 1a: 1 ⟹ Prod = Prod + Mcand 00001 00011000 0000011000
2: Shift left Multiplicand 00000 00110000 0000011000
3: Shift right Multiplier 00000 00110000 0000011000
6 Negate the product 00000 00110000 1111101000
FASTER MULTIPLICATION
Why is the multiplier with 32 adders faster?
- Original multiplier needs a clock cycle per bit
- Optimized multiplier needs:
•An “and” operation (parallel)
•32 adders (pipelined)
•Each adder receives output of previous multiplier
oLeast significant bit goes to result
o31 upper bits plus carry out go to next multiplier
- Pipeline latency:
•Cost of first multiply slow
•Following multiplies fast (presumably one per cycle)
MULTIPLICATION IN MIPS
• mult $t1, $t2 # t1 * t2
• multu $t1, $t2 # t1 * t2
• Two registers, Hi-Lo, operating as an extended 64-bit
register
• mflo $t3 # fetches 32 bits from Lo and store to $t3
• mfhi $t4 # fetches 32 bits from Hi and store to $t4
MULTIPLICATION IN MIPS
THANK YOU!!!

Vous aimerez peut-être aussi