Question: Implement the shift and add algorithm , which is used to perform multiplication in the old computer systems. The pseudo code is listed below. Write

Implement the shift and add algorithm , which is used to perform multiplication in the old computer systems. The pseudo code is listed below. Write an MIPS program that uses the algorithm.

Implement the shift and add algorithm , which is used to perform

multiplication in the old computer systems. The pseudo code is listed below.

A stores n-bit multiplicand B stores n-bit multiplier C is initialized as zero Repeat n times If LSB (least significant bit) of B-1 else C does not change shift C and B to the right by 1 bit, the LSB of C is shifted to the MSB in B add A to C product C concatenates B Example: calculate the product of 1101 and 1011 A 1101, B 1011, C 0000, n 4 iteration: LSB of B = 1, add A to C, 1101 1011 Shift C and B to the right by 1 bit 0110 1101 2 iteration LSB of B = 1, add A to C, 10011 Shift C and B to the right by 1 bit 1001 1101 1110 3 iteration LSB of B = 0, C does not change 1110 1001 Shift C and B to the right by 1 bit 0100 A stores n-bit multiplicand B stores n-bit multiplier C is initialized as zero Repeat n times If LSB (least significant bit) of B-1 else C does not change shift C and B to the right by 1 bit, the LSB of C is shifted to the MSB in B add A to C product C concatenates B Example: calculate the product of 1101 and 1011 A 1101, B 1011, C 0000, n 4 iteration: LSB of B = 1, add A to C, 1101 1011 Shift C and B to the right by 1 bit 0110 1101 2 iteration LSB of B = 1, add A to C, 10011 Shift C and B to the right by 1 bit 1001 1101 1110 3 iteration LSB of B = 0, C does not change 1110 1001 Shift C and B to the right by 1 bit 0100

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!