Difference between “addi” and “add” for pseudoinstruction “move” in MIPS?

The addi instruction requires an immediate operand rather than a register, so the $0 would actually be 0:

add   $rt, $rs, $0
addi  $rt, $rs, 0

Both will work and have all the needed information encoded into the instruction itself):

add   $d, $s, $t
    0000 00ss ssst tttt dddd d000 0010 0000
addi  $t, $s, i
    0010 00ss ssst tttt iiii iiii iiii iiii

However, it would be more usual to just use the zero-locked $0 register in this particular case since that is, after all, its purpose.

I would also tend to use the unsigned variant however, since I seem to recall there may be extra overflow checking done for signed instructions:

addu  $rt, $rs, $0

Leave a Comment