|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Pseudoinstructions: Set |
|
|
|
|
|
|
|
|
Instruction |
|
Real instructions |
|
Semantics |
|
|
|
Set if equal: |
|
|
seq $rd, $rs, $rt |
andi $rd, $rd, 0 |
# |
R[d] = (R[s] == R[t]) ? 1
: 0 |
|
|
bne $rs, $rt, next |
|
|
|
|
|
|
|
ori $rd, $zero, 1 |
|
|
|
|
|
|
|
|
next: |
|
|
|
|
|
|
|
|
What's wrong with this? |
|
|
|
|
|
|
|
|
Better way: |
|
|
|
|
|
|
|
xor $rd, $rs, $rt |
# |
R[d] = ~(R[s] == R[t]) |
|
|
|
sltiu $rd, $rd, 1 |
# |
R[d] = (R[d] < 1) |
|
|
Set if not equal: |
|
|
|
|
|
|
sne $rd, $rs, $rt |
|
# |
R[d] = (R[s] != R[t]) ? 1
: 0 |
|
|
xor $rd, $rs, $rt |
# |
R[d] = ~(R[s] == R[t]) |
|
|
|
sltu $rd, $0, $rd |
# |
R[d] = (R[d] > 0) |
|
|
Set if greater than or
equal: |
|
|
|
|
|
|
sge $rd, $rs, $rt |
|
# |
R[d] = (R[s] >= R[t])
? 1 : 0 |
|
|
|
slt $rd, $rs, $rt |
# |
R[d] = (R[s] < R[t]) ?
1 : 0 |
|
|
|
|
xori $rd, $rd, 1 |
# |
R[d] = ~R[d] |
|
|
|
Other combinations,
including unsigned: |
|
|
|
|
|
|
sgeu, sgt, sgtu, sle,
sleu |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|