Question: 4. [30 points] Write a C program to implement the Booth algorithm for multiplication of signed integers, as discussed in class. You may assume the

 4. [30 points] Write a C program to implement the Boothalgorithm for multiplication of signed integers, as discussed in class. You may

4. [30 points] Write a C program to implement the Booth algorithm for multiplication of signed integers, as discussed in class. You may assume the input a and b are small enough, i.e., only require 16-bit, so that the product c=ax b can fit into 32-bit. The following is a template for reading two integers a and b, and printing the product c = axb. #include void main() { int a, b, C; printf ("Enter an integer: "); scanf("%d", &a); printf ("Enter an integer: "); 1 scanf("%d", &b); C = 0; // product, initialized as 0. // the code of your subroutine multBooth is called below c = multBooth(a, b) printf("the product %d ", c); } Note: multiplication operation is not allowed in your subroutine. Note: multiplication operation is not allowed in your subroutine. The flow chart of Booth algorithm is given here. For this assignment, n = 16. start C+0; A sign extend to 2n-bit; B = 0; i+n 01 10 B.B. 00 11 C = C + A C = C-A A >1 i= 1-1 No i= 0? Yes end

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!