c.addi16sp
Add a sign-extended non-zero immediate
This instruction is defined by:
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.
Decode Variables
Bits<10> imm = {$encoding[12], $encoding[4:3], $encoding[5], $encoding[2], $encoding[6], 4'd0};
Execution
-
Pruned, XLEN == 64
-
Original
if ((%%LINK%csr_field;misa.C;CSR[misa].C%% == 1'b0)) {
%%LINK%func;raise;raise%%(ExceptionCode::IllegalInstruction, %%LINK%func;mode;mode%%(), $encoding);
}
X[2] = X[2] + $signed(imm);
if (%%LINK%func;implemented?;implemented?%%(ExtensionName::C) && (%%LINK%csr_field;misa.C;CSR[misa].C%% == 1'b0)) {
%%LINK%func;raise;raise%%(ExceptionCode::IllegalInstruction, %%LINK%func;mode;mode%%(), $encoding);
}
X[2] = X[2] + $signed(imm);