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 (d) (e) 3 (g) (h) (i)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
