C.ADDI

RISC-V C.ADDI Instruction Details

Instruction ManualCI format

Regular C.ADDI adds a nonzero sign-extended 6-bit immediate to a nonzero rd: rd += imm. CI format.

Instruction Syntax

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

Instruction Behavior

Regular C.ADDI uses the CI format to add a nonzero sign-extended 6-bit immediate to a nonzero rd and write rd; it expands to addi rd, rd, imm. Encodings with nonzero rd and imm=0 are HINTs. rd=x0 with imm=0 is C.NOP; C.NOP encodings with nonzero imm are also HINTs.

C.ADDI Decode And Execute Animation

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

Current Step

Step 1: identify C.ADDI

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

C.ADDI Execution Path
read old x10 = 0x0000000Csign-extend 6-bit imm to XLEN = -5write x10 = 0x00000007

This has the same calculation as addi rd, rd, imm; C.ADDI differs only in its 16-bit CI encoding and 6-bit immediate.

16-bit Encoding
0x156D = 0001010101101101
funct3 [15..13]
000
imm[5] [12]
1
rd [11..7]
01010
imm[4:0] [6..2]
11011
op [1..0]
01
Operands And Calculation
x10 = 0x0000000C
sext(imm[5:0]) = -5
0x0000000C + -5 (mod 2^32)
Decoded Result And Architectural State
C.ADDI

x10 = 0x00000007

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.ADDI is a 16-bit CI encoding for adding a signed 6-bit immediate to rd itself; the regular instruction form excludes rd=x0 and imm=0.

The immediate ranges from -32 to 31 and is sign-extended to XLEN before the addition.
Nonzero rd with imm=0 is a HINT; rd=x0 with imm=0 is C.NOP, so these encodings must not be shown as ordinary C.ADDI arithmetic.

Common Usage Scenarios

Basic Arithmetic

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

Loops & Iteration

Understand this scenario with real code like «c.addi 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.ADDI requires nonzero rd and nonzero imm; do not treat the imm=0 HINT as an addition.
rd=x0 with imm=0 is C.NOP, not regular C.ADDI.

FAQ

What immediate range does C.ADDI encode?

The CI format combines imm[5] and imm[4:0] into a signed 6-bit immediate, so it represents -32 through 31; regular C.ADDI does not use zero.