Question: 1. (10 points) Add comments to the following MIPS code and describe in one sentence what it computes. Assume that Sa0 is used for

1. (10 points) Add comments to the following MIPS code and describe in one sentence what it computes. Assume that Sa0 is used for the input and initially contains n, a positive integer. Assume that $v0 is used for the output. begin: addi $10, $zero, 0 addi St1, Szero, 1 loop: slt $t2, Sa0, St1 bne $t2, $zero, finish add $10, $10, $t1 addi $t1, $tl, 2 j loop $v0, $10, $zero finish: add 2. (10 points) Write MIPS code for the following high-level language program fragment: Loop: g g+A[i]; // Assume g is in $s1; i is in Ss3; base address of A is in $s5 i=i+j; // Assume j is in register $s4; h is in register $s2 if (i!=h) go to Loop
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
