Hi,
I will appreciate any help solving this programming question :
"You have just those 4 operations :
BEQ lable - jump to lable if the result of the last line equals zero
INC Rn - Increase Rn by one
DEC Rn - decrease Rn by one
RST Rn - initiate Rn to zero (nullify it)
You have to write a pseudo code for implementing multiplication of 2 numbers stored in R1 and R2. You can use additional registers."
I've wrote this code, but I find it difficult to translate it to pseudo code using just this 4 operations :
#include <stdio.h>
int main() {
int n, m, i,j, c = 0;
printf("enter 2 positive numbers you want the multiply result of\n");
scanf("%d , %d", &n,&m);
if ((n == 0) || (m == 0))
return 0;
for (i = n; i > 0; i--)
for (j = m; j > 0; j--)
c += 1;
printf("%d", c);
return c;
}
thanks!
I will appreciate any help solving this programming question :
"You have just those 4 operations :
BEQ lable - jump to lable if the result of the last line equals zero
INC Rn - Increase Rn by one
DEC Rn - decrease Rn by one
RST Rn - initiate Rn to zero (nullify it)
You have to write a pseudo code for implementing multiplication of 2 numbers stored in R1 and R2. You can use additional registers."
I've wrote this code, but I find it difficult to translate it to pseudo code using just this 4 operations :
#include <stdio.h>
int main() {
int n, m, i,j, c = 0;
printf("enter 2 positive numbers you want the multiply result of\n");
scanf("%d , %d", &n,&m);
if ((n == 0) || (m == 0))
return 0;
for (i = n; i > 0; i--)
for (j = m; j > 0; j--)
c += 1;
printf("%d", c);
return c;
}
thanks!