Search code examples
mipsmips32

How to add a register 's content as an immediate argument in a mips instruction?


I have a register called $offset which I can control. I would like to know how can I rewrite the lw command such that instead of the word off in

lw $a off($b) 

I have to the content of the $offset register.


Solution

  • MIPS assembly doesn't support this.

    What you will need to do instead is:

    add $c $b $offset
    lw  $a 0($c)