LI

Load Immediate

LI rd, imm

Loads an arbitrary immediate value into a register.

Encoding

Binary Layout
imm12
31:20
00000
19:15
000
14:12
rd
11:7
0010011
6:0
 
Format I-Type
Opcode 0x00000013
Extension Pseudo

Operands

  • rd
    Destination register (integer)
  • imm
    Immediate Value

Example

LI x5, 0x12345

// Expands to: LUI x5, 0x12; ADDI x5, x5, 0x345

Related

More in Pseudo

Description

LI loads an arbitrary immediate value into rd using one or two instructions (LUI+ADDI for 32-bit, or longer for 64-bit). It is an assembler pseudoinstruction. The encoding shown is the single-instruction case, ADDI rd, x0, imm, which applies when the immediate fits in 12 signed bits.

Operation

R[rd] = imm;