assemblymips

MIPS: Copy address of register to another register


So I'm having trouble copying the address of a register to another register. Currently I'm doing this:

la $a2, $a0

And I'm getting a syntax error. Does anyone know what's going on?


Solution

  • In order to treat the contents of $ao as an address rather than a number, put it into () like this:

    la $a2, ($a0)
    

    You could also use the move instruction:

    move $a2, $a0
    

    Kevin