Question: 24. Translate the following C program to Pep/9 assembly language. It multiplies two integers using an iterative shift-and-add algorithm. An iterative integer multiplication algorithm #include

24. Translate the following C program to Pep/9 assembly language. It multiplies two integers using an iterative shift-and-add algorithm.

An iterative integer multiplication algorithm

#include

int product, n, m;

void times(int *prod, int mpr, int mcand) {

*prod = 0;

while (mpr != 0) {

if (mpr % 2 == 1) {

*prod = *prod + mcand;

}

mpr /= 2;

mcand *= 2;

}

}

int main () {

scanf("%d %d", &n, &m);

times(&product, n, m);

printf("Product: %d", product);

return 0;

}

FIGURE 6.50 Trace of the run-time stack for Figure 6.25. (a) 2

FIGURE 6.50 Trace of the run-time stack for Figure 6.25. (a) 2 (d) (e) 3 (g) (h) (i)

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 Principles Algorithms And Systems Questions!