Why must a C.SWSP offset be a multiple of four?
Its compressed offset is word-scaled, forming a zero-extended byte offset multiplied by four.
Store 32-bit word to sp+offset. CSS format.
C.SWSP uses CSS format to store the low 32 bits of rs2 to the address formed by sp (x2) plus a zero-extended, 4-byte-scaled offset. It expands to sw rs2, offset(x2), and rs2 can be any integer register. The offset range is 0 through 252 bytes.
Shows only RISC-V ISA-visible 16-bit encoding, operands, and state; it does not simulate a pipeline, cache, endianness implementation, or timing.
The EEI choice affects this result only when the effective address is not divisible by 4; a naturally aligned access must not raise an address-misaligned exception.
mem[0x0000000000002010] <- 0x12345678
C.SWSP fixes x2/sp as its base, uses a 4-byte-multiple offset from 0 through 252, and stores the low 32 bits of rs2.
Understand this scenario with real code like «c.swsp x10, 16(sp) # *(sp+16) = x10».
Its compressed offset is word-scaled, forming a zero-extended byte offset multiplied by four.