C.LI

RISC-V C.LI Instruction Details

Instruction ManualCI format

Load a sign-extended 6-bit immediate into a nonzero rd: rd = imm. CI format.

Instruction Syntax

c.li rd, imm
Operand Breakdown
This is a CI format-format instruction. Confirm operand positions based on the assembly syntax.
CCompressed Instruction

Instruction Behavior

C.LI uses the CI format to write a sign-extended 6-bit immediate to a nonzero rd and expands to addi rd, x0, imm. rd is a full 5-bit field; encodings with rd=x0 are HINTs rather than ordinary C.LI writeback.

C.LI Decode And Execute Animation

Decodes the real 16-bit CR or CI encoding and distinguishes normal instructions, HINTs, and shared encodings.

Current Step

Concept Step: decode 16-bit fields

The animation shows C-extension 16-bit fields directly instead of pretending this is a 32-bit scalar instruction.

16-bit Encoding
0x556D = 0101010101101101
funct3 [15..13]
010
imm[5] [12]
1
rd [11..7]
01010
imm[4:0] [6..2]
11011
op [1..0]
01
Operands And Calculation
imm[5:0] = 111011
sext(imm[5:0]) = -5
source is x0 = 0
Decoded Result And Architectural State
C.LI

x10 = 0xFFFFFFFB

This animation shows only officially defined decode, register reads, arithmetic, and architectural state, not a particular implementation's pipeline, cache, prediction, or timing.

Quick Understanding & Search Notes

C.LI is a 16-bit CI encoding that writes a signed 6-bit immediate to rd; the regular form requires nonzero rd.

C.LI expands to addi rd, x0, imm, with the immediate sign-extended to XLEN.
rd is a full 5-bit field, but the rd=x0 encoding is a HINT; it is not a C.LI that changes x0.

Common Usage Scenarios

Immediates & Constants

Understand this scenario with real code like «c.li x10, 5 # x10 = 5».

Pre-Use Checklist

Syntax Check
  • Confirm the current instruction format is CI format.
  • Confirm the operand order matches the example.
Semantic Check
  • Ensure the destination register usage is compatible with the calling convention.
  • Confirm this is not the lower-level form of a pseudo-instruction expansion.

Pitfalls / Common Confusions

Regular C.LI requires nonzero rd; the rd=x0 encoding is a HINT and does not write an ordinary C.LI result.
The immediate is a signed 6-bit value from -32 through 31.

FAQ

Which immediates can C.LI load?

C.LI has a signed 6-bit CI immediate field, so it can load values from -32 through 31.