3. Multiplication

3.4. Optimized Multiplier

Untitled

3.5. Optimized Multiplier Example

Iteration Step Multiplicand Product
0 Initial values 0010 0000 0011
1 1 : 1 ⇒ Product += Multiplicand 0010 0011
2 : Shift Product right 0001 0001
2 1 : 1 ⇒ Product += Multiplicand 0011 0001
2 : Shift Product right 0001 1000
3 1 : 0 ⇒ no operation 0001 1000
2 : Shift Product right 0000 1100
4 1 : 0 ⇒ no operation 0000 1100
2 : Shift Product right 0000 0110
Iteration Step Multiplicand Product
0 Initial values 1000 0000 1001
1 1 : 1 ⇒ Product += Multiplicand 1000 1001
2 : Shift Product right 0100 0100
2 1 : 0 ⇒ no operation 0100 0100
2 : Shift Product right 0010 0010
3 1 : 0 ⇒ no operation 0010 0010
2 : Shift Product right 0001 0001
4 1 : 1 ⇒ Product += Multiplicand 1001 0001
2 : Shift Product right 0100 1000

3.6. Faster Multiplier

Untitled

3.7. MIPS Multiplication

Untitled

mult, multu : 64-bit product in HI/LO

mfhi, mflo : Move from HI/LO to rd, Can test HI value to see if product overflows 32 bits

mul : Least-significant 32 bits of product → rd

mult rs, rt / multu rs, rt

mfhi rd / mflo rd

mul rd, rs, rt