How to load and store word from/to address that index is in a register, MIPS

How to load and store word from address that index is in a register? in Assembly MIPS
Example:

lw $t0, $a0($t1)  and sw $t0,$a0($t1)  

Those intructions is just for what I will do (incorrect) Thanks


Solution 1:

Try doing this instead of your only lw statement:

add $a0 $a0 $t1
lw $t0 0($a0)
sub $a0 $a0 $t1

The last sub is needed only if you want to restore $a0 back to the original value.

You can do the same thing for the sw part.

Solution 2:

Microchip microcontrollers contain DSP-extensions with instructions:

LBUX rd, index(base)  # load byte
LHX rd, index(base)   # load half-word
LWX rd, index(base)   # load word

Where "index" and "base" is GPR registers.

But I did not find the same instructions for storing.