qwersjc
qwersjc

Reputation: 149

Question about translation between "jump" and "jump and link"

In the risc-v specification, it says that j is pseudocode for jal. I'm confused about how this works since the range of immediate values is different for j (25-bit immediate) and jal (20-bit immediate) - and also jalr with a 12-bit immediate.

Any clarification on how this translation is handled would be greatly appreciated!

Upvotes: 2

Views: 1307

Answers (1)

FabienM
FabienM

Reputation: 3761

No, immediate value size is not different for j and jal as official documentation say:

Plain unconditional jumps (assembler pseudoinstruction J) are encoded as a JAL with rd=x0.

Following instruction :

j offset

Will expand to

jal x0, offset

Maybe you thought that the 5bits that encode the rd register (x0) was included in offset, but not.

Upvotes: 6

Related Questions