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

Vol. 1 7-11
PROGRAMMING WITH GENERAL-PURPOSE INSTRUCTIONS
For the purpose of this discussion, these instructions are divided subordinate
subgroups of instructions that:
Add and subtract
Increment and decrement
Compare and change signs
Multiply and divide
7.3.2.1 Addition and Subtraction Instructions
The ADD (add integers), ADC (add integers with carry), SUB (subtract integers), and
SBB (subtract integers with borrow) instructions perform addition and subtraction
operations on signed or unsigned integer operands.
The ADD instruction computes the sum of two integer operands.
The ADC instruction computes the sum of two integer operands, plus 1 if the CF flag
is set. This instruction is used to propagate a carry when adding numbers in stages.
The SUB instruction computes the difference of two integer operands.
The SBB instruction computes the difference of two integer operands, minus 1 if the
CF flag is set. This instruction is used to propagate a borrow when subtracting
numbers in stages.
7.3.2.2 Increment and Decrement Instructions
The INC (increment) and DEC (decrement) instructions add 1 to or subtract 1 from
an unsigned integer operand, respectively. A primary use of these instructions is for
implementing counters.
7.3.2.3 Increment and Decrement Instructions in 64-Bit Mode
The INC and DEC instructions are supported in 64-bit mode. However, some forms of
INC and DEC (the register operand being encoded using register extension field in
the MOD R/M byte) are not encodable in 64-bit mode because the opcodes are
treated as REX prefixes.
7.3.2.4 Comparison and Sign Change Instruction
The CMP (compare) instruction computes the difference between two integer oper-
ands and updates the OF, SF, ZF, AF, PF, and CF flags according to the result. The
source operands are not modified, nor is the result saved. The CMP instruction is
commonly used in conjunction with a Jcc (jump) or SETcc (byte set on condition)
instruction, with the latter instructions performing an action based on the result of a
CMP instruction.