jal address
jalr
Instruction
The jal
instruction is used when
the address of the subroutine is known at assembly time.
For example, here is how main
would usually
call the first subroutine:
jal sub1
But what if you want to call the first subroutine in a
jump table?
You can't say jal sub1add
jalr r # $ra <― PC+4 $ra <― address 8 bytes away from the jal # PC <― $r load the PC with the subroutine entry point in $r
This works just like the jal