DDCA Ch6 - Part 14: Jumps & Pseudoinstructions
New Section
In this section, the speaker delves into the details of RISC-V assembly language, focusing on jump instructions and pseudo instructions.
Understanding Jump Instructions
- Jump and link instruction adds a 21-bit immediate value to the program counter in two's complement form, allowing jumps forward or backward by up to a million. It also specifies a destination register for storing PC plus 4.
- Jump and link register is similar but uses a source register and immediate value to set the PC. It also links the return address into a designated register.
Pseudo Instructions in RISC-V
- RISC-V introduces pseudo instructions that are not actual instructions but are converted by the assembler for convenience. For instance, "jump to some label" translates to "jump and link x0, label," utilizing register x0 which is hardwired to zero.
- The use of pseudo instructions simplifies programming tasks by providing more straightforward syntax while achieving the same functionality as complex jump instructions.
Exploring Labels and Extended Jumps
This part focuses on labels in RISC-V assembly language, explaining their role in indicating jump destinations and how extended jumps are facilitated.
Labels for Jumping
- Labels serve as markers for jump destinations in RISC-V assembly code, represented as immediate offsets from the current instruction's memory location.
- The offset specified by a label determines the distance to jump from the current instruction, aiding in efficient program flow control within limited bit constraints.
Extending Jump Reach
- To enable longer jumps beyond standard limits, an additional instruction called "add upper immediate pc" is utilized. This instruction allows setting a destination register based on the current PC plus an immediate value stored in its upper bits.