Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Convert the high level language conditional instructions to MIPS assembly: if (i

ID: 3852650 • Letter: C

Question

Convert the high level language conditional instructions to MIPS assembly:

if (i == j)

f = g + h;

else

f = g - h;

Let:

$s3 contain the value of i

$s4 contain the value of j

$s1 contain the value of g

$s2 contain the value of h

add $s0, $s1, $s2

j Exit

Else: sub $s0, $s1, $s2

Exit:

add $s0, $s3, $s4

j Exit

Else: sub $s0, $s3, $s4

Exit:

add $s0, $s1, $s2

Else: sub $s0, $s1, $s2

add $s0, $s1, $s2

j Exit

Else: sub $s0, $s1, $s2

Exit:

A. bne $s3, $s4, Exit

add $s0, $s1, $s2

j Exit

Else: sub $s0, $s1, $s2

Exit:

B. bne $s3, $s4, Else   

add $s0, $s3, $s4

j Exit

Else: sub $s0, $s3, $s4

Exit:

C. bne $s3, $s4, Else   

add $s0, $s1, $s2

Else: sub $s0, $s1, $s2

D. bne $s3, $s4, Else   

add $s0, $s1, $s2

j Exit

Else: sub $s0, $s1, $s2

Exit:

Convert the high level language conditional instructions to MIPS assembly: f=g+h; else =g-h; Let: . $s3 contain the value of i $$4 contain the value of j . $s1 contain the value of g . $s2 contain the value of h bne $s3, $s4, Exit add $s0, $s1, $s2 j Exit Else: sub $s0, $s1, $s2 Exit: bne $s3, $s4, Else add $s0, $s3, $S4 j Exit Else: sub $s0, $s3, $s4 Exit bne $s3, $s4, Else add $s0, $s1, $s2 Else: sub $s0, $s1, $s2 bne $s3, $s4, Else add $s0, $s1, $s2 j Exit Else: sub $s0, $s1, $s2 Exit:

Explanation / Answer

Answer is : D

add $s0, $s1, $s2 #f = g + h;

j Exit

Else: sub $s0, $s1, $s2 #f = g - h;

Exit:

D. bne $s3, $s4, Else #if (i == j)   

add $s0, $s1, $s2 #f = g + h;

j Exit

Else: sub $s0, $s1, $s2 #f = g - h;

Exit: