I am new to assembly coding and I came across a problem that says to transfer the following C code to MIPS assembly.
b[8] = b[i-j] + x ;
and variables i,j,x are in registers 7,4 and 15 and base address of array b is in 2,870,220 decimal.
I came up with the following solution
lui $2, 0x002B
ori $2, $2, 0xCBCC
sub $3, $7, $4
add $3, $2, $3
lw $12, 0($3)
addu $12, $12, $15
sw $12, 32($2)
but when I checked the answer, there was one additional line of
sll $3, $3, 2
after the subtract instruction.
Could someone please explain why do we need to multiply the content of register $3 by 4 ?