Question: Convert the high level language loop to MIPS assembly: while (save[ i] == k) i += 1; i and k are in $s3 and $s5

Convert the high level language loop to MIPS assembly:

while (save[ i] == k)

i += 1;

i and k are in $s3 and $s5 and base of array save[ ] is in $s6.

A.
Loop: sll $t1, $s3, 2 

add $t1, $t1, $s6

lw $t0, 0($t1)

bne $t0, $s5, Exit

addi $s3, $s3, 1

j Loop

Exit:

B.
Loop: sll $t1, $s3, 2 

add $t1, $t1, $s6

lw $t0, 4($t1)

bne $t0, $s5, Loop

addi $s3, $s3, 1

Loop: j Loop

Exit:

C.
Loop: sll $t1, $s3, 1 

add $t1, $t1, $s6

lw $t0, 0($t1)

bne $t0, $s5, Exit

addi $s3, $s3, 1

j Loop

Exit:

D.
 Loop: sll $t1, $s3, 2 

add $t1, $t1, $s6

lw $t0, 0($t1)

bne $t0, $s5, Exit

addi $s3, $s3, 4

j Loop

Exit:

Convert the high level language loop to MIPS assembly: while (save[ i]

Convert the high level language loop to MIPS assembly: while (save ik) i += 1; i and k are in $s3 and $5 and base of array save ] is in $s6. Loop: sll St1, Ss3, 2 add $t1, $t1, $s6 lw $to, 0($t1) bne $t0, $s5, Exit addi $s3, $s3, 1 j Loop Exit: O B. Loop: sll St1, Ss3, 2 add $t1, $t1, $s6 lw $to, 4($t1) bne $to, $s5, Loop addi $s3, $s3, 1 Loop: j Loop Exit: O C. Loop: sl St1, Ss3, 1 add $t1, $t1, $s6 lw $to, 0($t1) bne $t0, $s5, Exit addi $s3, $s3, 1 j Loop Exit: O D. Loop: sll St1, Ss3. 2 add $t1, $t1, $s6 lw $to, 0($t1) bne $t0, $s5, Exit addi $s3, $s3, 4 j Loop Exit

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!