We know that jal
specifies a 21-bit offset. However, it does not encode a 21-bit offset but a 20-bit one. The reason is that the least significant bit of an address is always zero because the smallest possible RISC-V instruction is 2 bytes, so this bit is not encoded in the instruction.
By encoding the offset this way it can provide a jumping range of ±1MiB. If jal
did encode the LSB, it would offer just a ±512KiB jumping range.
However, the jalr
instruction, which specifies a 12-bit offset, does encode the LSB. This reduces the jumping range to ±2kiB (instead of ±4kiB). I know that jalr
uses the I-type format, which is the same as addi
and the LSB of the immediate has to be encoded for this kind of instructions. However, I see no reason why the least significant bit has to be encoded for jalr
.