0

When using MIPS assembly code, I have been using the li command a lot to store a constant in a register. However, I am trying to take some of my code and decompose all of the pseudo instructions into normal MIPS instructions.

From research, I understand that li translates into two instructions: lui and ori.

For example,

li $8, 0x3BF20 translates to

lui $8, 0x0003

ori $8, $8, 0xBF20

However, I am not quite sure what lui and ori do, and I am not sure how it produces the same result as li.

Midgar77
  • 19
  • 1
  • 6

2 Answers2

2

lui (Load Upper Immediate) is loading the upper half of the register & clearing the lower half; ori (OR Immediate) is "loading" the lower half by oring the register w/ the value to go in the lower half.

Scott Hunter
  • 48,888
  • 12
  • 60
  • 101
1

read the manual, one modifies the whole register half zeros half what you specify the other does a logical or of 16 bits against the register (in this case hitting the other 16 bits that lui zeroed)

old_timer
  • 69,149
  • 8
  • 89
  • 168