Question: Please help with understanding this question in detail. It is using MIPS. Thanks! 3. (15 points) This C segment while (A[i]!k) uses both a conditional

Please help with understanding this question in detail. It is using MIPS. Thanks!

Please help with understanding this question in detail. It is using MIPS.

3. (15 points) This C segment while (A[i]!k) uses both a conditional branch and an unconditional jump each time through the loop (see below). Variables i, j, and k correspond to registers Ss3, Ss4, and Ss5, and the base (start address) of the integer array A in Ss6. The result of the program is the final value of the index i in Ss3 Code before optimization Loop: addStl, Ss3, Ss3 # Temporary register $t1-1*2 add Stl add , St, Ss6 lw beq StO, $s5, Exit add Ss3. Ss3, $s4 , $tl, Stl # Temporary register $t-1*4 # Temporary register St-address of Ali] # Temporary register $t0-A[i] # goto Exit if Ali-k #i-i+) # goto Loop StO, 0(Stl) Loop Exit a. (13 points) Rewrite the assembly code so that it executes at most one branch or jump each time through the loop (i.e., no more than one jump/branch executed per iteration). b. (2 points) If the number of times when (AIi]-k) is true is 10, what is the number of instructions executed before and after optimization

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!