ISARef Multi-ISA & Silicon Reference
45,419 ISA items · 105,907 timings · 913 microarchs · 15,555 chips · 105 sources
Arch:
Tier:

c.addi4spn

T1 riscv alu insn
Add a zero-extended non-zero immediate, scaled by 4, to the stack pointer
SourceRISC-V Official Unified Database (riscv-unified-db) (riscv_unified_db)
Reliability TierT1 — Official Specification
ISA / Silicon ScopeRV32/RV64 Zca
RV32 / RV64 (Ratified & Standard Extensions)
License & VersionApache-2.0 / CC-BY-4.0
main
Upstreamhttps://github.com/riscv/riscv-unified-db
Privilegeuser
ExtensionsZca

Summary

Adds a zero-extended non-zero immediate, scaled by 4, to the stack pointer, x2, and writes the result to xd'. This instruction is used to generate pointers to stack-allocated variables. It expands to addi xd', x2, nzuimm[9:2]. C.ADDI4SPN is only valid when nzuimm ≠ 0; the code points with nzuimm=0 are reserved.

Syntax / Encoding

c.addi4spn xd, sp, imm | 000xxxxxxxxxxx00 (mask=0xe003 match=0x0000)

Binary Encodings (1)

WidthFormatBit PatternMask / Match
16RV000xxxxxxxxxxx000xe003 / 0x0000

Operands

NameDescription
immbits [10:7,12:11,5,6], shifted << 2, not 0
xdbits [4:2]

Reference Notes

Adds a zero-extended non-zero immediate, scaled by 4, to the stack pointer, x2, and writes the result to xd'.
This instruction is used to generate pointers to stack-allocated variables.
It expands to `addi xd', x2, nzuimm[9:2]`.
C.ADDI4SPN is only valid when nzuimm &ne; 0; the code points with nzuimm=0 are reserved.