|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Set instructions |
|
|
|
|
Notice that the branch
instructions include: |
|
|
equality, inequality |
|
|
relational operations
compared to zero |
|
|
What about general
comparison? |
|
|
Example: $rs < $rt |
|
|
Need more instructions to
compare 2 values directly |
|
|
|
Instruction |
|
Semantics |
|
Comparison |
|
|
slt $rd, $rs, $rt # R[d] = R[s] < R[t] ? 1 : 0 |
2C |
|
|
sltu $rd, $rs, $rt # R[d] = R[s] < R[t] ? 1 : 0 |
UB |
|
|
slti $rt, $rs, immed # R[d] = R[s] < immed ? 1 : 0 |
2C |
|
|
sltiu $rt, $rs,
immed # R[d] = R[s] < immed ? 1
: 0 |
UB |
|
|
|
|
|
|
|
|
|
Compare 2 registers or
register and a constant. |
|
|
|
|
If condition is true,
result is set to 1, else 0 (note conditional operator). |
|
|
Immediate value must be
extended with sign bit (2C) or zero (unsigned). |
|
|
Note that this only sets
a value; a separate instruction is needed to do a branch. |
|
|
What about >
operation? |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|