Given the following C code:
B = A[i - j]
Assuming B = $s7, A = $s6, i = $s3 and j = $s4
What would the assembly code be?
sub $s3, $s3, $s4 # i - j sll $s3, $s3, 2 # multiply the offset by 4 add $s3, $s3, $s6 # add the offset to the base address. I'm hoping to get a new address as return. Correct? lw $s3, 0($s3) # load from the made up address sw $s3, 16($s7) # saves
I can't find a version of lw that takes a register as the offset. Is this correct?