# `li`

[RISC-V Documentation](https://asm-editor.specy.app/documentation/risc-v.md) › [Instructions](https://asm-editor.specy.app/documentation/risc-v/instruction.md)

Web page: https://asm-editor.specy.app/documentation/risc-v/instruction/li

**Load immediate** · Pseudo-instruction

Category: Data movement

Loads an immediate constant into a register, using as many instructions as the value needs.

[RISC-V manual: addi](https://docs.riscv.org/reference/isa/v20260120/unpriv/rv32.html#norm:addi_op)

Used in: [Loads, stores and immediates](https://asm-editor.specy.app/learn/courses/risc-v/introduction/loads-stores-and-immediates.md) (RISC-V assembly), [Asking a question with a branch](https://asm-editor.specy.app/learn/courses/risc-v/introduction/asking-a-question-with-a-branch.md) (RISC-V assembly), [.data, .text and directives](https://asm-editor.specy.app/learn/courses/risc-v/introduction/data-text-and-directives.md) (RISC-V assembly), [Going 64-bit](https://asm-editor.specy.app/learn/courses/risc-v/introduction/going-64-bit.md) (RISC-V assembly), [if, else and jump tables](https://asm-editor.specy.app/learn/courses/risc-v/think-in-assembly/if-else-and-jump-tables.md) (RISC-V assembly), [Loops](https://asm-editor.specy.app/learn/courses/risc-v/think-in-assembly/loops.md) (RISC-V assembly), [Arithmetic, logic and bits](https://asm-editor.specy.app/learn/courses/risc-v/think-in-assembly/arithmetic-logic-and-bits.md) (RISC-V assembly), [Arrays and strings](https://asm-editor.specy.app/learn/courses/risc-v/think-in-assembly/arrays-and-strings.md) (RISC-V assembly), [The stack and sp](https://asm-editor.specy.app/learn/courses/risc-v/think-in-assembly/the-stack-and-sp.md) (RISC-V assembly), [jal, ret and the calling convention](https://asm-editor.specy.app/learn/courses/risc-v/think-in-assembly/jal-ret-and-the-calling-convention.md) (RISC-V assembly)

## Forms

- `li t1, imm`
  - `li t1,-100`: Set t1 to 12-bit immediate (sign-extended) → `addi t1, zero, imm`
  - `li t1,10000000`: Set t1 to 32-bit immediate → `lui t1, hi(imm)`; `addi t1, t1, lo(imm)`
  - `li t1,1000000000000000`: Set t1 to 64-bit immediate → `lui t1, imm[63:44]`; `addiw t1, t1, imm[43:32]`; `slli t1, t1, 11`; `addi t1, t1, imm[31:21]`; `slli t1, t1, 11`; `addi t1, t1, imm[20:10]`; `slli t1, t1, 10`; `addi t1, t1, imm[9:0]`

## Operands

- `t1`: Any integer register, `x0` to `x31`, or its named alias, such as `zero`, `t0` or `t6`.
- `imm`: An immediate value: a signed 12-bit value (`-2048` to `2047`), a 32-bit value (`-2147483648` to `4294967295`) or a 64-bit value in RV64 (signed decimal or a hexadecimal bit pattern up to `0xFFFFFFFFFFFFFFFF`). The size your value needs decides which real instructions the assembler uses. Open the row to see them for each size.

## Example

```riscv64
# li writes 123 to t0.
.data
marker: .word 17
.text
li t0, 123
```
