lui

Load upper immediate

Puts a 16-bit immediate into the upper half of $t1 and clears the lower half, often as the first step of a 32-bit constant.

Forms

  • lui ,

Pseudo-instructions

The assembler turns these into one or more real instructions.

  • Set $t1 to the upper 16 bits of label's address, adjusted so that a following %lo lands on the label. Pairs with an instruction taking %lo(label)($t1)

Operands

$t1
Any general-purpose register, $0 to $31, using its numeric or named spelling, such as $8 or $t0 ($zero is $0; $ra is $31).
uimm16
An unsigned 16-bit immediate, 0 to 65535.
label
A named address in the program, such as the start of a loop or a variable in .data.

Used to build a full 32-bit constant: first 'lui $t1,upper16' then 'ori $t1,$t1,lower16'. Example: to load 0x12345678 use 'lui $t1,0x1234' then 'ori $t1,$t1,0x5678'.

# Place 0x1234 in the upper half of $t0. Inspect $t0: 0x12340000.
lui $t0, 0x1234