[0x00400000] 0x3c011000 lui $1, 4096 ; 5: li $t0, 0x100000F4
[0x00400004] 0x342800f4 ori $8, $1, 244
[0x00400008] 0x8d100000 lw $16, 0($8) ; 6: lw $s0, 0($t0)
the above is my spim program, I am curious about the li instruction getting divied into lui and ori could anyone explain what is going on there?
any help appreciated thanks!!
li is a pseudo-instruction (ie, it doesn't exist as an opcode on processors). it is always expanded into a 'load upper immediate'; and an 'or with immediate' instruction:
effectively: (4096 << 16) || 244
The lui
instruction will be skipped if the number is not large; and ori
will or with the 0 register.