overflow flag (OF). This is because the arithmetic instructions use OF for indi-
cating signed overflows.
Table A.3 Signed Conditional Codes Table for CMPand SUBInstructions
SATISFIED
MNEMONICS FLAGS WHEN COMMENTS
If Greater (G) ZF = 0 AND X> Y Use ZF to confirm
If Not Less or ((OF = 0 AND SF = 0) OR that the operands
Equal (NLE) (OF = 1 AND SF = 1)) are unequal. Also use
SF to check for either
a positive result
without an overflow,
indicating that the first
operand is greater, or
a negative result with
an overflow. The latter
would indicate that
the second operand
was a low enough
negative integer to
produce a result too
large to be
represented by the
destination (hence the
overflow).
If Greater or (OF = 0 AND SF = 0) OR X>= Y This code is similar
Equal(GE) (OF = 1 AND SF = 1) to the preceding
If Not Less (NL) code with the
exception that it
doesn’t check ZF for
zero, so it would also
be satisfied by equal
operands.
If Less (L) (OF = 1 AND SF = 0) OR X< Y Check for OF = 1 AND
If Not Greater (OF = 0 AND SF = 1) SF = 0 indicating that
or Equal (NGE) Xwas lower than Y
and the result was too
low to be represented
by the destination
operand (you got an
overflow and a
positive result). The
other case is OF = 0
AND SF = 1. This is a
similar case, except
that no overflow is
generated, and the
result is negative.
484 Appendix A
21_574817 appa.qxd 3/16/05 8:52 PM Page 484