MIPS - Address out of range when calling sw

Viewed 19

What I'm trying to do is a for (i = 0, i < n, i++) vector[i] = i * i; loop in the MARS IDE for Assembly MIPS.

However, I'm running in an error: Runtime exception at 0x00400010: address out of range 0x00000000

Here is the code for said loop (I get the same error regardless where the loop is located in the code).

The array is saved at $s0, the index at $t1.

    storevalues:
    mul $t2, $t1, $t1               # $t2 = i * i;
    add $t5, $t1, $t1               # $t5 = 2i
    add $t5, $t5, $t5               # $t5 = 4i.
    add $t5, $t5, $s0               # $t5 = Squares[i]
    sw $t2, 0 ($t5)                 # Squares[i] = $t2 || ERROR HERE
    addi $t1, $t1, 1                # i++
    blt $t1, $t0, storevalues       # Back to the start of the loop
0 Answers
Related