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 uses opcode 0110111 (0x37). The 20-bit immediate is loaded into the upper 20 bits of rd, with lower 12 bits zero-filled.
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.
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.