[prev] 17 [next]

Exercise 5: Mapping while

Implement the following in MIPS assembler

sum = 0; i = 1;
while (i <= 20) {
   sum = sum + i;
   i++;
}

Assume that i and sum are mapped to registers

And, of course, the above is equivalent to:

sum = 0;
for (i = 1; i <= 20; i++)
   sum += i;