BGTZ 000111 |
rs |
0 00000 |
offset |
6 |
5 |
5 |
16 |
BGTZ rs, offset |
MIPS32 |
Branch on Greater Than Zero |
Branch on Greater Than Zero
To test a GPR then do a PC-relative conditional branch.
if GPR[rs] > 0 then branch
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 zero (sign bit is 0 but value not zero), branch to the effective target address after the instruction in the delay slot is executed.
Control Transfer Instructions (CTIs) should not be placed in branch delay slots or Release 6 forbidden slots. CTIs
include all branches and jumps, NAL, ERET, ERETNC, DERET, WAIT, and PAUSE.
Pre-Release 6: Processor operation is UNPREDICTABLE if a control transfer instruction (CTI) is placed in the delay slot of a branch or jump.
Release 6: If a control transfer instruction (CTI) is executed in the delay slot of a branch or jump, Release 6 implementations are required to signal a Reserved Instruction exception.
I: target_offset = sign_extend(offset || 02) condition = GPR[rs] > 0GPRLEN 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 (J) or jump register
(JR) to branch to addresses outside this range.