# `lui`

[MIPS Documentation](https://asm-editor.specy.app/documentation/mips.md) › [Instructions](https://asm-editor.specy.app/documentation/mips/instruction.md)

Web page: https://asm-editor.specy.app/documentation/mips/instruction/lui

**Load upper immediate**

Category: Data movement

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

## Forms

- `lui $t1, uimm16`

## Pseudo-instructions

The processor does not have these forms. The assembler replaces each of them with one or more real instructions. Open a row to see them.

- `lui $t1, %hi(label)` · 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)
  - `lui $t1,%hi(label)` → `lui $t1, hi(label)`

## 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`.

## Description

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'.

## Example

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