
Chapter 3: General-Purpose Programming
39
24593—Rev. 3.09—September 2003
AMD 64-Bit Technology
The effects that rFLAGS bit-values have on instructions are
summarized in the following places:
Conditional Moves (CMOV
cc
)—Table 3-4 on page 51.
Conditional Jumps (J
cc
)—Table 3-5 on page 66.
Conditional Sets (SET
cc
)—Table 3-6 on page 71.
The effects that instructions have on rFLAGS bit-values are
summarized in “Instruction Effects on RFLAGS” in Volume 3.
The sections below describe each application-visible flag. All of
these flags are readable and writable. For example, the POPF,
POPFD, POPFQ, IRET, IRETD, and IRETQ instructions write
all flags. The carry and direction flags are writable by dedicated
application instructions. Other application-visible flags are
written indirectly by specific instructions. Reserved bits and
bits whose writability is prevented by the current values of
system flags, current privilege level (CPL), or the current
operating mode, are unaffected by the POPF
x
instructions.
Carry Flag (CF).
Bit 0. Hardware sets the carry flag to 1 if the last
integer addition or subtraction operation resulted in a carry
(for addition) or a borrow (for subtraction) out of the most-
significant bit position of the result. Otherwise, hardware clears
the flag to 0.
The increment and decrement instructions—unlike the
addition and subtraction instructions—do not affect the carry
flag. The bit shift and bit rotate instructions shift bits of
operands into the carry flag. Logical instructions like AND, OR,
XOR clear the carry flag. Bit-test instructions (BTx) set the
value of the carry flag depending on the value of the tested bit
of the operand.
Software can set or clear the carry flag with the STC and CLC
instructions, respectively. Software can complement the flag
with the CMC instruction.
Parity Flag (PF).
Bit 2. Hardware sets the parity flag to 1 if there is
an even number of 1 bits in the least-significant byte of the last
result of certain operations. Otherwise (i.e., for an odd number
of 1 bits), hardware clears the flag to 0. Software can read the
flag to implement parity checking.
Auxiliary Carry Flag (AF).
Bit 4. Hardware sets the auxiliary carry
flag to 1 if the last binary-coded decimal (BCD) operation