Question: This c segment While (A[i]= k) i = i + j uses both a conditional branch and an unconditional jump each time through the loop

This c segment

This c segment While (A[i]= k) i = i + j uses

While (A[i]= k) i = i + j uses both a conditional branch and an unconditional jump each time through the loop (see below). Variables j j, and k correspond to registers Ss3, Ss4, and Ss5, and the base (start address) of the integer array A in $s6. The result of the program is the final value of the index i in Ss3. Code before optimization Loop: add $t1, $s3, $s3 # Temporary register $t1 = j*2 add $t1, $t1, $t1 # Temporary register $t1 = j*4 add $t1, $t1, $s6 # Temporary register $t1 = address of A[i] lw $t0, 0($t1) # Temporary register $t0 = A[i] beq $t0, $s5, Exit # goto Exit if A[i] ! = k add $s3, $s3, $s4 #i = i + j j Loop # goto Loop Exit: a. 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)

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!