Reputation: 23
[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!!
Upvotes: 1
Views: 366
Reputation: 8116
li is load immediate. However, the value that you're trying to load is too big to fit into the immediate data section of that instruction. The assembler therefore splits it up into two instructions that each load half of that value into the upper and lower parts of that register.
Upvotes: 0
Reputation: 4311
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.
Upvotes: 2