U-type Upper Immediate
LUI places the 20-bit U-immediate in the upper portion of rd and clears the low 12 bits. On RV64, the 32-bit result is sign-extended to XLEN.
RISC-V Unprivileged ISA, RV32I integer computational instructionsLoad a 20-bit immediate into the upper 20 bits of rd, filling the lower 12 bits with zeros
LUI (U-type, opcode=0110111) places the 20-bit U-immediate value into the destination register rd, filling the lowest 12 bits with zeros. Used to build 32-bit constants, typically paired with ADDI. When rd=x0, the encoding is reserved for HINT instructions.
Uses the same rhythm as the ADDI page: machine-code fields, fixed-field identification, operand reads, instruction-specific execution, and ISA-visible state update.
The machine code is split by the current instruction format; the animation starts from encoding/decode.
This animation shows ISA-visible decode and state changes, not any specific CPU pipeline, cache, prediction, or timing implementation.
LUI places the U-immediate into the upper portion of rd and clears the low 12 bits, commonly as the first step when forming larger constants.
These notes are checked against the RISC-V Unprivileged ISA manual and summarize operation semantics, immediate ranges, and edge behavior.
LUI places the 20-bit U-immediate in the upper portion of rd and clears the low 12 bits. On RV64, the 32-bit result is sign-extended to XLEN.
RISC-V Unprivileged ISA, RV32I integer computational instructionsUnderstand this scenario with real code like «lui x5, 0x12345 # x5 = 0x12345 << 12 = 0x12345000».
No. LUI sets the upper 20 bits and clears the low 12 bits; a full constant usually needs a following instruction such as ADDI.
LUI forms a value from the immediate alone; AUIPC adds the upper-immediate offset to the current PC.