The following problems deal with translating from C to MIPS. Assume that the variables f,g,h,i, and j are assigned to registers $s0, $s1, $s2, $s3, and $s4, respectively. Assume that the base address of the arrays A and B are registers $s6 and $s7, respectively. Write the MIPS code for the following C lines of code: I am trying to mimic the following code snippet from a C program and write it in MIPS.
if(g != h){
f = A[3];
} else{
f = B[4];
}
Below is the MIPS I have so far
bne $s1, $s2, Tru
lw $s0, 16($s7)
j Done
Tru: lw $t0, 12($s6)
add $s0, $t0, $zero
Done:
If I was unclear please comment below.