Is it always equivalent to a same-named 32-bit instruction?
Not always. Some C/Zc instructions compress common 32-bit operations, while others have dedicated stack-frame or table-jump semantics.
Add zero-extended non-zero imm scaled by 4 to sp, result to rd'. CIW format.
C.ADDI4SPN (CIW format) adds zero-extended non-zero immediate scaled by 4 to sp(x2), writes to rd' (x8-x15 only). Expands to addi rd',x2,nzuimm[9:2]. Valid only when nzuimm≠0. Used to generate pointers to stack-allocated variables.
Connect 16-bit fields to compressed constraints, base-instruction semantics, and visible architectural state.
sp = 0x0000000000001000, offset = 16x8 = 0x000000000000101016-bit encoding and field roles
Visible calculation
Fixed x2 is the input base; rd' is the sole writeback target.
Field reconstruction and address generation
rd' -> x8 (x8-x15)nzuimm[9:2] = 00000100; low bits = 00addi x8, x2, 16x8 <- 0x0000000000001010C.ADDI4SPN is the 16-bit encoding form for compressed add sp plus nonzero immediate; its semantics and encodable register/immediate ranges must be read from the official C extension rules.
Understand this scenario with real code like «c.addi4spn x8, 16 # x8 = sp+16».
Understand this scenario with real code like «c.addi4spn x8, 16 # x8 = sp+16».
Not always. Some C/Zc instructions compress common 32-bit operations, while others have dedicated stack-frame or table-jump semantics.
Many 16-bit encodings can represent only a compressed register subset or fixed registers such as sp, ra, a0/a1.