b label == beq $0,$0,offset
Here is a table of branch instructions. There are additional branch instructions used for subroutine linkage that have been omitted. Some instructions assume 32-bit two's complement data; others assume 32-bit unsigned data. Some instructions don't assume any data format.
The first operand s
must be a register.
The second operand t
may be a register or a
immediate operand
(the extended assembler will generate the correct basic instructions
depending on which you choose).
The label designates address that can be reached with by adding
a 16-bit, sign-extended integer to the PC.
This means it must be roughly plus or minus 32K from the current instruction.
Mnemonic | Operands | Description | signed or unsigned? |
b | label | branch | |
beq | s,t,label | branch if s==t | |
beqz | s,label | branch if s==0 | |
bge | s,t,label | branch if s>=t | signed |
bgeu | s,t,label | branch if s>=t | unsigned |
bgez | s,label | branch if s>=0 | signed |
bgt | s,t,label | branch if s>t | signed |
bgtu | s,t,label | branch if s>t | unsigned |
bgtz | s,label | branch if s>0 | signed |
ble | s,t,label | branch if s<=t | signed |
bleu | s,t,label | branch if s<=t | unsigned |
blez | s,label | branch if s<=0 | signed |
blt | s,t,label | branch if s<t | signed |
bltu | s,t,label | branch if s<t | unsigned |
bltz | s,label | branch if s<0 | signed |
bne | s,t,label | branch if s=/=t | |
bnez | s,label | branch if s=/=0 |
Some of the pseudoinstructions use the assembler temporary register ($at, or register $1) in the one or two basic instructions they are expanded to.