For this pseudoinstruction:
move $rt, $rs
Are both the addi and add assembly code acceptable? So could I use either
add $rt, $rs, $0
or
addi $rt, $rs, $0
?
Edit:
I think I made a mistake with addi
add $rt, $rs, $0
would be the same as
addi $rt, $rs, 0
since add
adds registers, and I need a constant for the immediate for addi
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