Hello I am new to MIPS assembly language and Im trying to write the equivalent of B[8]=A[i-j] where variables f, g, h, i, and j are assigned to registers $s0, $s1, $s2, $s3, and $s4, respectively. I assume that the base address of the arrays A and B are in registers $s6 and $s7, respectively.
My code
# Gets A[i-j]
sub $t1, $s3, $s4
sll $t1, $t1, 2
add $t1, $s6, $t1
lw $t0, 0($t1)
# Set B[8] equal to above
addi $t2, $s0, 8
sll $t2, $t2, 2
add $t2, $s7, $t2
lw $t2, 0($t2)
sw $t2, 0($t0)
but this throws a runtime exception at 0x0040000c: address out of range 0x00000000, any advice?
$s6actually contains a valid address? And what values do you have in$s3and$s4? - Michael