Intel 64 and IA-32 Architectures Software Developers Manual Volume 1, Basic Architecture
7-12 Vol. 1
PROGRAMMING WITH GENERAL-PURPOSE INSTRUCTIONS
The NEG (negate) instruction subtracts a signed integer operand from zero. The
effect of the NEG instruction is to change the sign of a two's complement operand
while keeping its magnitude.
7.3.2.5 Multiplication and Divide Instructions
The processor provides two multiply instructions, MUL (unsigned multiply) and IMUL
signed multiply), and two divide instructions, DIV (unsigned divide) and IDIV (signed
divide).
The MUL instruction multiplies two unsigned integer operands. The result is
computed to twice the size of the source operands (for example, if word operands are
being multiplied, the result is a doubleword).
The IMUL instruction multiplies two signed integer operands. The result is computed
to twice the size of the source operands; however, in some cases the result is trun-
cated to the size of the source operands (see “IMUL—Signed Multiply” in Chapter 3,
“Instruction Set Reference, A-M,” of the Intel® 64 and IA-32 Architectures Software
Developer’s Manual, Volume 3A).
The DIV instruction divides one unsigned operand by another unsigned operand and
returns a quotient and a remainder.
The IDIV instruction is identical to the DIV instruction, except that IDIV performs a
signed division.
7.3.3 Decimal Arithmetic Instructions
Decimal arithmetic can be performed by combining the binary arithmetic instructions
ADD, SUB, MUL, and DIV (discussed in Section 7.3.2, “Binary Arithmetic Instruc-
tions”) with the decimal arithmetic instructions. The decimal arithmetic instructions
are provided to carry out the following operations:
• To adjust the results of a previous binary arithmetic operation to produce a valid
BCD result.
• To adjust the operands of a subsequent binary arithmetic operation so that the
operation will produce a valid BCD result.
These instructions operate on both packed and unpacked BCD values. For the
purpose of this discussion, the decimal arithmetic instructions are divided subordi-
nate subgroups of instructions that provide:
• Packed BCD adjustments
• Unpacked BCD adjustments
7.3.3.1 Packed BCD Adjustment Instructions
The DAA (decimal adjust after addition) and DAS (decimal adjust after subtraction)
instructions adjust the results of operations performed on packed BCD integers