Overview
A number of instructions operate with respect to the condition code registers.
CMP and TEST
Instruction | Operands | Based On | Description |
---|---|---|---|
cmp[bwlq] | Compare | ||
test[bwlq] | Test |
SET
The description of the SET
commands apply to the case of a comparison instruction. That is, the condition codes are set according to computation t = a - b
, where t
, a
, and b
may be interpreted as signed or unsigned depending on the SET
instruction invoked.
Instruction | Synonym | Evaluation | Description |
---|---|---|---|
sete | setz | ZF | Equal / zero |
setne | setnz | ~ZF | Not equal / not zero |
sets | SF | Negative | |
setns | ~SF | Nonnegative | |
setl | setnge | SF ^ OF | Less (signed < ) |
setle | setng | (SF ^ OF) | ZF | Less or equal (signed <= ) |
setg | setnle | ~(SF ^ OF) & ~ZF | Greater (signed > ) |
setge | setnl | ~(SF ^ OF) | Greater or equal (signed <= ) |
setb | setnae | CF | Below (unsigned < ) |
setbe | setna | CF | ZF | Below or equal (unsigned <= ) |
seta | setnbe | ~CF & ~ZF | Above (unsigned > ) |
setae | setnb | ~CF | Above or equal (unsigned >= ) |
Note how the other condition code evaluations are easy to derive from setl
and setb
.
Bibliography
- Bryant, Randal E., and David O’Hallaron. Computer Systems: A Programmer’s Perspective. Third edition, Global edition. Always Learning. Pearson, 2016.