Originally posted by GuyPerfect
EDIT:
Incidentally, what is the proper MIPS instruction for loading from immediate data? I wound up using ADDI with a source register of r0, but that feels like I'm taking the long way around. Then again, knowing that all MIPS instructions are 32 bits, I can't really think of anything an immediate move could do that an immediate add to r0 can't.
That's how you're supposed to do it.
If you use an assembler, you'd use the
LI pseudoinstruction:
li $a0, 0x12345678
li $a1, 0x0000abcd
li $a2, 0xffffabcd
If your assembler is any good, it'll have multiple translations:
lui $a0, 0x1234
ori $a0, $a0, 0x5678
ori $a1, $zero, 0xabcd
addiu $a2, $zero, 0xabcd
And a good disassembler will recognize some of those to show you something like this:
lui $a0, 0x1234
ori $a0, $a0, 0x5678
li $a1, 0x0000abcd
li $a2, 0xffffabcd
____________________
ふにゃあ。