Question: Consider the following C++ code and MIPS translation MIPS while (a[i] -k) Loop: sll $t1, $s3, 2 add $t1, $t 1, $66 # St1 address

 Consider the following C++ code and MIPS translation MIPS while (a[i]

Consider the following C++ code and MIPS translation MIPS while (a[i] -k) Loop: sll $t1, $s3, 2 add $t1, $t 1, $66 # St1 address of a[i] bne $t0, $s5, Exit # exit loop if save [i] != k addi $s3, $s3, 1 j Loop Exit: .. . (a) Assuming the first value where a[i] k is when i-10, determine the number of MIPS instructions executed by the loop if i starts at 0 (b) In the above code two branch/jump instructions are executed for each loop iteration (except the last). This turns out not to be optimal. Rewrite the above code so that only 1 branch/jump instruction is executed for each loop. Determine the total number of instructions executed using the conditions stated in part (a)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!