Instruction
AAD
Turns the unpacked BCD digits in AH and AL into the binary number AL plus AH times the immediate base (10 as assembled) before a DIV; not in 64-bit mode.
- Extensions
- Forms
- 1 (1 Legacy)
- Data
- Intel XED v2026.08.23
AAD joins two unpacked BCD digits, the high one in AH and the low one in AL, into a binary number: AL becomes AL plus AH times the base, kept to 8 bits, and AH is cleared. The base is 10 unless the immediate byte says otherwise. With AX = 0708h, the digits 7 and 8, AAD gives AX = 004Eh, 78, which a DIV by an unpacked digit then divides into a quotient digit in AL and a remainder in AH, the step that long division of a BCD number by one digit repeats. SF, ZF and PF follow the new AL; OF, AF and CF are undefined.
Where AAM fixes up after the operation, AAD runs before
it, since DIV needs a binary dividend; the two are inverses for values
below the square of the base. Like AAM’s, the base is the second byte of
the instruction, D5 0A for plain AAD: both manuals say that other bases
are coded by hand, while GNU as 2.44 and Clang 23 take aad $8 in AT&T
syntax. Unlike AAM, AAD has no division, so a base of 0 raises nothing:
AL stays and AH is cleared.
Not in 64-bit mode
Opcode D5 raises #UD in 64-bit mode, so the fixture has no case for AAD:
the probe runs there and lists the form as not run. GNU as 2.44 and
Clang 23 refuse aad in 64-bit code, and GCC 14 and Clang 23 have no
intrinsic for it. In our builds with -m32,
(ax >> 8) * 10 + (ax & 0xff) compiles at -O2 to LEA and SHR in GCC 14
and Clang 23, and at -Os to an IMUL in GCC 14. AMD’s Zen 5 guide lists
AAD as microcoded, without a latency.
Forms
| Instruction | Encoding | Requires |
|---|---|---|
AAD imm8 not in 64-bit mode
AAD_IMMb | D5 ib | Base instruction set |
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
r = (al + ah * base) & 0xFF # base is 10 in plain AAD
ax = r # AH cleared
sf = r >> 7 & 1
zf = r == 0
pf = parity(r)
of = af = cf = UNDEFINEDNot run on a processor: the instruction does not exist in 64-bit mode, where the probe runs.
Operands
| Operand | Kind | Action |
|---|---|---|
AAD imm8 not in 64-bit mode | ||
imm8 | explicit | read |
AL | implicit | read, write |
AH | implicit | read, write |
RFLAGS | implicit | write |
Flags
| OF | SF | ZF | AF | PF | CF |
|---|---|---|---|---|---|
| All forms | |||||
| U | M | M | U | M | U |
CPUID and processors
Each form belongs to an XED ISA set. A form can be used when the processor reports every CPUID bit of one of its ISA set's alternatives.
| ISA set | CPUID | Processors |
|---|---|---|
I86 | No CPUID bit: part of the base instruction set. | Every x86-64 processor in XED’s model and Zen 3 to Zen 6 |
More General-purpose instructions
Sources
- Intel XED v2026.08.23 (commit
0bcb6237345c): forms, encodings, operands, flags, exception classes, attributes, ISA sets, CPUID bits and chip model. - The CPU data of x86-64.net: Zen 3 to Zen 6, from GCC’s
-marchfeature sets and AMD’s Processor Programming References, which the page of each processor cites. - Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-093, September 2026): Volume 2A, page 3-3 (AAD)
- AMD64 Architecture Programmer's Manual, Volume 3: General-Purpose and System Instructions (24594, rev. 3.39, October 2026)
- Software Optimization Guide for the AMD Zen5 Microarchitecture (58455, rev. 1.00, August 2024), Wayback Machine copy of AMD's ZIP
The tables are derived from Intel XED, Copyright Intel Corporation, licensed under the Apache License 2.0; x86-64.net converted and reformatted them. The text is our own.