c.addi16sp

Add a sign-extended non-zero immediate

This instruction is defined by:

Encoding

svg

Synopsis

C.ADDI16SP adds the non-zero sign-extended 6-bit immediate to the value in the stack pointer (sp=x2), where the immediate is scaled to represent multiples of 16 in the range (-512,496). C.ADDI16SP is used to adjust the stack pointer in procedure prologues and epilogues. It expands into addi x2, x2, nzimm[9:4]. C.ADDI16SP is only valid when nzimm ≠ 0; the code point with nzimm=0 is reserved.

Access

M

HS

U

VS

VU

Always

Always

Always

Always

Always

Decode Variables

Bits<10> imm = {$encoding[12], $encoding[4:3], $encoding[5], $encoding[2], $encoding[6], 4'd0};

Execution

  • Pruned, XLEN == 64

  • Original

X[2] = X[2] + imm;
if (implemented?(ExtensionName::C) && (CSR[misa].C == 1'b0)) {
  raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
}
X[2] = X[2] + imm;