Question: 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
![3. (15 points) This C segment while (A[i] != k) uses](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f4623ce5be7_96466f4623ca0ec1.jpg)
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: add St1, ss3, Ss3 add St1, St1, St1 add St, St1, Ss6 lw beq St0, Ss5, Exit add s3, Ss3, Ss4 # Temporary register $t1 = 1*2 # Temporary register St1-74 # Temporary register St-address of A[i] # Temporary register $t0 = Ali] # goto Exit if A [i] = k St0, 0(St1) Loop # goto 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 (A i] '-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
Get step-by-step solutions from verified subject matter experts
