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

in MIPS please Q6. (4 marks): For the following C statement, what is the corresp

ID: 3912475 • Letter: I

Question

in MIPS please

Q6. (4 marks): For the following C statement, what is the corresponding MIPS assembly code? Assume that the variables a, b, and c are assigned to register $s0, $s1, and $s2, respectively Q7. (5 marks): Assume that the variables i and j are assigned to registers $s0, and $s1, respectively. Assume that the base address of the arrays A and B are in registers $s2, and $s4, respectively. Consider that the element of the arrays A and B are 4-byte words. Translate the following C code to MIPS.

Explanation / Answer

1.

addi $s2, $s2, -8

add $s0,$s1,$s2

2.

sub $t1,$s0,$s1

sll $t0, $t1, 2 # offset = i * 4
add $t0, $s2, $t0 # base + offset

lw $t1 48($s4)

lw $t1, 0( $t0 )