Link Address
JAL writes the address of the next instruction (pc+4) to rd. With rd=x0, no return address is saved, so it acts as an unconditional jump.
RISC-V Unprivileged ISA, RV32I control transfer instructionsJump to PC-relative offset, storing return address (PC+4) in rd
JAL uses opcode 1101111 (0x6f). The 21-bit immediate encodes the jump offset (±1 MiB), and rd receives the return address (pc+4).
JAL uses the J-type format (opcode=1101111), where the J-immediate encodes a signed offset in multiples of 2 bytes. The offset is sign-extended and added to the JAL instruction address, yielding a ±1 MiB range. JAL stores PC+4 into rd. When rd=x0, it acts as an unconditional jump (pseudo J). When rd=x1 or x5, hardware may use RAS prediction. An instruction-address-misaligned exception is raised on a misaligned target.
JAL is a PC-relative jump-and-link: the target is the J-type offset plus the current PC, and pc+4 is written to rd. With rd=x0, it jumps without saving a return address.
These notes are checked against the RISC-V Unprivileged ISA manual and summarize operation semantics, immediate ranges, and edge behavior.
JAL writes the address of the next instruction (pc+4) to rd. With rd=x0, no return address is saved, so it acts as an unconditional jump.
RISC-V Unprivileged ISA, RV32I control transfer instructionsThe J-type immediate encodes a signed PC-relative offset in 2-byte units, giving JAL an approximate reach of +/-1 MiB from the current PC.
RISC-V Unprivileged ISA, RV32I control transfer instructionsUnderstand this scenario with real code like «jal x1, 0x100 # jump to pc+0x100, x1 = pc+4».
Understand this scenario with real code like «jal x1, 0x100 # jump to pc+0x100, x1 = pc+4».
JAL writes the next instruction address, pc+4, into rd.
Use JAL for a direct PC-relative target nearby. Use JALR when the target comes from a register or from an AUIPC+JALR sequence.