c.jal
Jump and Link
This instruction is defined by:
Synopsis
C.JAL is an RV32C-only instruction that performs the same operation as C.J, but additionally writes the address of the instruction following the jump (pc+2) to the link register, x1.
It expands to jal x1, offset
.
Decode Variables
signed Bits<12> imm = sext({$encoding[12], $encoding[8], $encoding[10:9], $encoding[6], $encoding[7], $encoding[2], $encoding[11], $encoding[5:3], 1'd0});
Execution
-
Pruned, XLEN == 32
-
Original
if ((%%LINK%csr_field;misa.C;CSR[misa].C%% == 1'b0)) {
%%LINK%func;raise;raise%%(ExceptionCode::IllegalInstruction, %%LINK%func;mode;mode%%(), $encoding);
}
XReg retrun_addr = $pc + 2;
%%LINK%func;jump_halfword;jump_halfword%%($pc + $signed(imm));
X[1] = retrun_addr;
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);
}
XReg retrun_addr = $pc + 2;
%%LINK%func;jump_halfword;jump_halfword%%($pc + $signed(imm));
X[1] = retrun_addr;