Intel 64 and IA-32 Architectures Software Developers Manual Volume 1, Basic Architecture

3-22 Vol. 1
BASIC EXECUTION ENVIRONMENT
This flag indicates an overflow condition for unsigned-integer arith-
metic. It is also used in multiple-precision arithmetic.
PF (bit 2) Parity flag — Set if the least-significant byte of the result contains
an even number of 1 bits; cleared otherwise.
AF (bit 4) Adjust flag — Set if an arithmetic operation generates a carry or a
borrow out of bit 3 of the result; cleared otherwise. This flag is used
in binary-coded decimal (BCD) arithmetic.
ZF (bit 6) Zero flag — Set if the result is zero; cleared otherwise.
SF (bit 7) Sign flag — Set equal to the most-significant bit of the result, which
is the sign bit of a signed integer. (0 indicates a positive value and 1
indicates a negative value.)
OF (bit 11) Overflow flag — Set if the integer result is too large a positive
number or too small a negative number (excluding the sign-bit) to fit
in the destination operand; cleared otherwise. This flag indicates an
overflow condition for signed-integer (two’s complement) arithmetic.
Of these status flags, only the CF flag can be modified directly, using the STC, CLC,
and CMC instructions. Also the bit instructions (BT, BTS, BTR, and BTC) copy a spec-
ified bit into the CF flag.
The status flags allow a single arithmetic operation to produce results for three
different data types: unsigned integers, signed integers, and BCD integers. If the
result of an arithmetic operation is treated as an unsigned integer, the CF flag indi-
cates an out-of-range condition (carry or a borrow); if treated as a signed integer
(two’s complement number), the OF flag indicates a carry or borrow; and if treated
as a BCD digit, the AF flag indicates a carry or borrow. The SF flag indicates the sign
of a signed integer. The ZF flag indicates either a signed- or an unsigned-integer
zero.
When performing multiple-precision arithmetic on integers, the CF flag is used in
conjunction with the add with carry (ADC) and subtract with borrow (SBB) instruc-
tions to propagate a carry or borrow from one computation to the next.
The condition instructions Jcc (jump on condition code cc), SETcc (byte set on condi-
tion code cc), LOOPcc, and CMOVcc (conditional move) use one or more of the status
flags as condition codes and test them for branch, set-byte, or end-loop conditions.
3.4.3.2 DF Flag
The direction flag (DF, located in bit 10 of the EFLAGS register) controls string
instructions (MOVS, CMPS, SCAS, LODS, and STOS). Setting the DF flag causes the
string instructions to auto-decrement (to process strings from high addresses to low
addresses). Clearing the DF flag causes the string instructions to auto-increment
(process strings from low addresses to high addresses).
The STD and CLD instructions set and clear the DF flag, respectively.