Describe what $t0 and $t2 will be when the loop completes. Describe in as much d
ID: 3533382 • Letter: D
Question
Describe what $t0 and $t2 will be when the loop completes. Describe in as much detail as possible.
the label the contents of registers Sto and St2 when the following MIPS program reaches "Done". Register sso contains the base address of an int array of size Assume that integer values have been B 10 inputted into the array B already. addi St1, $s0, 36 lw St0, 0($t1) subi St1, St1, 4 r Loop: blt stl, sso, Done if St1 is less than sso, go to Done lw St2, 0 ($t1) bgt St2, sto, Skip if St2 greater than St0, go to Skip addi St0, St 2, 0 Skip: subi St1, St 1, 4 Done:Explanation / Answer
when loop completes,
$t2= $s0 ,$t0=$s0 and //$t1= $s0-4 (which is $t1[0]= $s0[-1]) .
explanation(equivalent C code):
//here $t1 and $s0 are arrays and $t2,$t0 are normal int variables.
initially at the starting of the loop , $t1=$s0+36 and $t0=$t1[0]=$s0[9]
while($t1>=$s0){
$t2=$t1[0]; //which is equal to $s0[9] in first loop
if($t2<=$t0)$t0=$t2+0;
$t1=$t1-4; // which implies after each loop $t1[0] =$s0[8],$s0[7], so on..
}