REGIMM 000001 |
rs |
BGEZAL 10001 |
offset |
6 |
5 |
5 |
16 |
BGEZAL rs, offset |
MIPS32, removed in Release 6 |
Branch on Greater Than or Equal to Zero and Link |
Branch on Greater Than or Equal to Zero and Link
To test a GPR then do a PC-relative conditional procedure call
if GPR[rs] >= 0 then procedure_call
Place the return address link in GPR 31. The return link is the address of the second instruction following the branch, where execution continues after a procedure call.
An 18-bit signed offset (the 16-bit offset field shifted left 2 bits) is added to the address of the instruction following the branch (not the branch itself), in the branch delay slot, to form a PC-relative effective target address.
If the contents of GPR rs are greater than or equal to zero (sign bit is 0), branch to the effective target address after the instruction in the delay slot is executed.
Availability and Compatibility
This instruction has been removed in Release 6 with the exception of special case BAL (unconditional Branch and
Link) which was an alias for BGEZAL with rs=0.
Processor operation is UNPREDICTABLE if a control transfer instruction (CTI) is placed in the delay slot of a branch or jump.
Branch-and-link Restartability: GPR 31 must not be used for the source register rs, because such an instruction does
not have the same effect when reexecuted. The result of executing such an instruction is UNPREDICTABLE. This restriction permits an exception handler to resume execution by reexecuting the branch when an exception occurs in the branch delay slot or forbidden slot.
I: target_offset = sign_extend(offset || 02) condition = GPR[rs] >= 0GPRLEN GPR[31] = PC + 8 I+1: if condition then PC = PC + target_offset endif
None
With the 18-bit signed instruction offset, the conditional branch range is ± 128 KBytes. Use jump and link (JAL) or jump and link register (JALR) instructions for procedure calls to addresses outside this range.
BGEZAL r0, offset, expressed as BAL offset, is the assembly idiom used to denote a PC-relative branch and link.
BAL is used in a manner similar to JAL, but provides PC-relative addressing and a more limited target PC range.