![](http://datasheet.mmic.net.cn/370000/-PD30101_datasheet_16680756/-PD30101_58.png)
CHAPTER 2 CPU INSTRUCTION SET SUMMARY
27
For more information about computational instructions, refer to the individual instruction as described in
Chapter 24.
2.2.3 Jump and Branch Instructions
Jump and branch instructions change the control flow of a program. All jump and branch instructions
occur with a delay of one instruction: that is, the instruction immediately following the jump or branch
instruction (this is known as the instruction in the delay slot) always executes while the target instruction
is being fetched from memory.
For instructions involving a link (such as JAL and BLTZAL), the return address is saved in register r31.
Table 2-4. Number of Delay Slot Cycles in Jump and Branch Instructions
Instruction
Necessary number of cycles
Branch instruction
1
Jump instruction
1
(1) Overview of jump instructions
Subroutine calls in high-level languages are usually implemented with J or JAL instructions, both of
which are J-type instructions. In J-type format, the 26-bit target address shifts left 2 bits and combines
with the high-order 4 bits of the current program counter to form a 32-bit or 64-bit absolute address.
Returns, dispatches, and cross-page jumps are usually implemented with the JR or JALR instructions.
Both are R-type instructions that take the 32-bit or 64-bit byte address contained in one of the general-
purpose registers.
For more information, refer to Chapter 24.
(2) Overview of branch instructions
All branch instruction target addresses are computed by adding the address of the instruction in the
delay slot to the 16-bit offset (shifted left 2 bits and sign-extended to 64 bits). All branches occur with a
delay of one instruction.
If a branch likely instruction is not taken, the instruction in its delay slot is nullified. For all other branch
instructions, the instruction in its delay slot is unconditionally executed.
For more information, refer to Chapter 24.
Remark
The target instruction of the branch is fetched at the EX stage of the branch instruction.
Comparison of the operands of the branch instruction and calculation of the target address is
performed at phase 2 of the RF stage and phase 1 of the EX stage of the instruction. Branch
instructions require one cycle of the branch delay slot defined by the architecture. Jump
instructions also require one cycle of delay slot. If the branch condition is not satisfied in a
branch likely instruction, the instruction in its delay slot is nullified.
2.2.4 Special Instructions