Write a MIPS assembly routine whose signature looks like this:
unsigned int round(unsigned int a, unsigned int b)"
round(a,b) should return the integer c which is equal to integer a rounded
to integer b. For instance, round(15, 10) = 10, round(27, 9) = 27,
round(8, 3) = 6. You may assume that a is always greater than b at the
time round is called. It is tempting to solve this problem using a division
instruction. Instead (to gain familiarity with control flow instructions), you
should implement your routine using repeated subtractions from the first argument, and repeated additions to the result register.
The pseudo-code should look roughly like this:
int res = 0;
while(a >= b) {
a -= b;
res += b;
}
return res;