| Pseudoinstructions: Branch | ||||||||||||
| How do we compare values in 2 registers? | ||||||||||||
| Instructions for beq, bne, but not for general relational operators | ||||||||||||
| result | ||||||||||||
| slt $rd, $rs, $rt | R[s] < R[t] | 1 | ||||||||||
| R[s] >= R[t] | 0 | |||||||||||
| Instruction | Real instructions | Semantics | ||||||||||
| bge $rs, $rt, LABEL | slt $at, $rs, $rt | if (R[s] >= R[t]) | ||||||||||
| beq $at, $zero, LABEL | goto LABEL | |||||||||||
| bgt $rs, $rt, LABEL | slt $at, $rt, $rs | if (R[s] > R[t]) | ||||||||||
| bne $at, $zero, LABEL | goto LABEL | |||||||||||
| ble $rs, $rt, LABEL | slt $at, $rt, $rs | if (R[s] <= R[t]) | ||||||||||
| beq $at, $zero, LABEL | goto LABEL | |||||||||||
| blt $rs, $rt, LABEL | slt $at, $rs, $rt | if (R[s] < R[t]) | ||||||||||
| bne $at, $zero, LABEL | goto LABEL | |||||||||||
| Note that LABEL must be converted to an offset from PC | ||||||||||||
| What about immediate value? | ||||||||||||
| bge $rs, immed, LABEL | ||||||||||||