C.LUI

Compressed Load Upper Immediate

C.LUI rd, imm

Loads a non-zero 6-bit immediate into bits 17-12 of the destination register, clears lower 12 bits, sign-extends bit 17.

Details

Loads a 18-bit sign-extended value (upper 6 bits of 20-bit immediate) into rd (≠ x0, x2).

Pseudocode Operation

R[rd] = sext(imm << 12);

Example

C.LUI x10, 1

Encoding

Binary Layout
?
31:16
011
15:13
c_nzimm18hi
12
rd_n2
11:7
c_nzimm18lo
6:2
01
1:0
 
Format CI
Opcode 0x00006001
Extension C

Operands

  • rd
    Destination register (integer)
  • imm
    Signed immediate value