# `li`

[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/li

**Load immediate** · Pseudo-instruction

Category: Data movement

Puts an immediate value into a register, using one or two instructions as its size needs.

Used in: [Getting started with MIPS](https://asm-editor.specy.app/learn/courses/mips/introduction/getting-started.md) (MIPS assembly), [The 32 registers and their names](https://asm-editor.specy.app/learn/courses/mips/introduction/the-32-registers.md) (MIPS assembly), [.data, .text and directives](https://asm-editor.specy.app/learn/courses/mips/introduction/data-text-and-directives.md) (MIPS assembly), [Memory, little endian and alignment](https://asm-editor.specy.app/learn/courses/mips/introduction/memory-little-endian-and-alignment.md) (MIPS assembly), [Words, halves and bytes](https://asm-editor.specy.app/learn/courses/mips/introduction/words-halves-and-bytes.md) (MIPS assembly), [The MIPS instruction set](https://asm-editor.specy.app/learn/courses/mips/introduction/the-mips-instruction-set.md) (MIPS assembly), [Loads, stores and immediates](https://asm-editor.specy.app/learn/courses/mips/introduction/loads-stores-and-immediates.md) (MIPS assembly), [Comparing two numbers](https://asm-editor.specy.app/learn/courses/mips/introduction/comparing-two-numbers.md) (MIPS assembly), [Memory regions and executable files](https://asm-editor.specy.app/learn/courses/mips/introduction/memory-regions-and-executable-files.md) (MIPS assembly), [Branch on compare](https://asm-editor.specy.app/learn/courses/mips/think-in-assembly/branch-on-compare.md) (MIPS assembly)

## Forms

- `li $t1, imm`
  - `li $t1,-100`: Set $t1 to 16-bit immediate (sign-extended) → `addiu $t1, $zero, imm`
  - `li $t1,100`: Set $t1 to unsigned 16-bit immediate (zero-extended) → `ori $t1, $zero, imm`
  - `li $t1,100000`: Set $t1 to 32-bit immediate → `lui $at, hi(imm)`; `ori $t1, $at, lo(imm)`

## 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`).
- `imm`: An immediate value: a signed 16-bit value (`-32768` to `32767`), an unsigned 16-bit value (`0` to `65535`) or a 32-bit value (`-2147483648` to `4294967295`). The size your value needs decides which real instructions the assembler uses. Open the row to see them for each size.

## Example

```mips
# Load a literal directly into $t2; inspect it for 7.
li $t2, 7
```
