Why is the C.ADDI16SP immediate range not every integer?
The immediate is encoded with a 16-byte scale, so only nonzero multiples of 16 from -512 through 496 are encodable.
Add nonzero sign-extended nzimm[9:4] to stack pointer x2/sp; the immediate is a multiple of 16 bytes. CI format; it shares encoding space with C.LUI.
C.ADDI16SP shares encoding space with C.LUI but fixes the destination field to x2/sp. It sign-extends scattered nonzero nzimm[9:4] and adds it to x2/sp; this immediate represents 16-byte multiples from -512 through 496. It expands to addi x2, x2, nzimm[9:4]; the nzimm=0 encoding is reserved.
Decodes the real 16-bit CR or CI encoding and distinguishes normal instructions, HINTs, and shared encodings.
0x713D = 0111000100111101The animation shows C-extension 16-bit fields directly instead of pretending this is a 32-bit scalar instruction.
Before the writeback step, x2/sp retains the read old value; the calculation above is pending writeback.
This animation shows only officially defined decode, register reads, arithmetic, and architectural state, not a particular implementation's pipeline, cache, prediction, or timing.
C.ADDI16SP is a 16-bit C-extension instruction: it reads and writes fixed x2/sp and adds sign-extended nonzero nzimm[9:4]. It encodes only 16-byte multiples from -512 through 496.
Understand this scenario with real code like «c.addi16sp -32 # sp -= 32».
The immediate is encoded with a 16-byte scale, so only nonzero multiples of 16 from -512 through 496 are encodable.
C.ADDI16SP is valid only when nzimm is nonzero; the nzimm=0 encoding is reserved.