The following are the direct jump and link operations in 32-bit RISC-V:
| Operation | Description |
| :-------: | :-----------------------------------------------------------: |
| jalrdlabel | Set rd to PC+4 (the line after the current line) and branch to [label]. |
| jalrrdrs1imm | Set rd to PC+4 and jump to the line of code at rs1 + imm. |
Note!
There are two pseudoinstructions used when we do not need to return after a call:
Direct jumps to label using jlabel, which stands for jalx0label.
Direct jumps to address using jrrs1, which stands for jalrx0rs10.
C Loop
In C or any high-level programming language, one would write code in the following manner:
int A[20];int sum = 0;for (int i = 0; i < 20; i++) { sum += A[i]}printf("%d\n", sum)
In the RISC-V low-level language, however, such abstractions are not possible. However, we can roughly translate the C code above into RISC-V, assuming that x8 contains the address of the int array: