18. Translate the following C program to Pep/9 assembly language. It multiplies two integers using a recursive

Question:

18. Translate the following C program to Pep/9 assembly language. It multiplies two integers using a recursive shift-and-add algorithm. mpr stands for multiplier and mcand stands for multiplicand.

A recursive integer multiplication algorithm #include
int times(int mpr, int mcand) {
if (mpr == 0) {
return 0;
}
else if (mpr % 2 == 1) {
return times(mpr / 2, mcand * 2) + mcand;
}
else {
return times(mpr / 2, mcand * 2);
}
}
int main() {
int n, m;
scanf("%d %d", &n, &m);
printf("Product: %d", times(n, m));
return 0;
}

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

Computer Systems

ISBN: 9781284079630

5th Edition

Authors: J Stanley Warford

Question Posted: