Download presentation
Presentation is loading. Please wait.
Published byVivian Jefferson Modified over 6 years ago
1
CSCI206 - Computer Organization & Programming
Integer Multiplication zyBook: 10.3
2
2’s Complement Multiplication
For powers of 2, multiply is trivial (shift left). else use elementary algorithm:
3
Algorithm In general, multiplying a M bit number times a N bit number results in M + N bits multiplicand multiplier product = 0 for i in range(0, N): if multiplier[i] == 1: product += multiplicand << i product
4
Signed Multiplication
This algorithm works for unsigned numbers. For signed numbers, multiply the absolute values and then add the proper sign to the result.
5
Signed Multiplication
Resulting sign is + x + = + + x - = - - x + = - - x - = + In general: xor of input sign bits to get resulting sign bit
6
The Multiplier multiplicand x multiplier Setup multiplicand in lower half of multiplicand register (2n bits) multiplier in multiplier register (n bits) product register is zero (2n bits)
7
The Multiplier
8
0010 x 0011 = ???? Example 1
9
0010 x 0011 = 0110
10
Product is the MIPS hi/lo registers
Optimized Multiplier Product is the MIPS hi/lo registers Multiplier is initialized in the left half of the product register. Now we shift product register right. The multiplicand is 32-bits and not shifted because the result is written to the correct position in the product register after 32 right shifts.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.