Instruction
DAA
Corrects AL after adding two packed BCD numbers so that it holds two decimal digits, setting CF on a decimal carry; not in 64-bit mode.
- Extensions
- Forms
- 1 (1 Legacy)
- Data
- Intel XED v2026.08.23
DAA turns the binary sum of two packed BCD bytes in AL, each holding two decimal digits, into the packed BCD sum. An ADD of 58h and 47h leaves 9Fh: the low digit is above 9, so DAA adds 6 (A5h), and AL was above 99h, so it adds 60h, leaving 05h with CF set, which is 105 written in decimal. The two tests use AL and CF as they were before DAA: the low digit is corrected when it exceeds 9 or AF reports a carry out of it, the high one when AL exceeded 99h or CF reports a carry out of the byte. AF and CF then say which corrections were made, SF, ZF and PF follow the result, and OF is undefined.
A longer number is added a byte at a time from the low end, ADD then ADC for each further byte, with a DAA after each, CF carrying the decimal carry to the next byte. DAS is the same for a subtraction, AAA the unpacked form with one digit per byte.
The manuals’ wording
AMD’s Volume 3 says that AF and CF are left alone where no correction is made, and Intel’s pseudocode clears them; it comes to the same, since a set AF or CF forces its correction. Both give OF as undefined.
Not in 64-bit mode
Opcode 27 raises #UD in 64-bit mode, and the fixture has no case for DAA
for that reason: the probe runs there and lists the form as not run. GNU
as 2.44 and Clang 23 refuse daa in 64-bit code, and GCC 14 and
Clang 23 have no intrinsic for it. Packed BCD of up to 18 digits
converts to and from binary in one instruction each with x87’s
FBLD and FBSTP, which 64-bit mode kept.
AMD’s Zen 5 guide lists DAA as microcoded, without a latency.
Forms
| Instruction | Encoding | Requires |
|---|---|---|
DAA not in 64-bit mode
DAA | 27 | Base instruction set |
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
a = al
c = cf
r = a
if (a & 0xF) > 9 or af: # the low digit overflowed
r += 6
af = 1
else:
af = 0
if a > 0x99 or c: # the high digit, by AL and CF as they
r += 0x60 # were before the instruction
cf = 1
else:
cf = 0
al = r
sf = r >> 7 & 1
zf = (r & 0xFF) == 0
pf = parity(r)
of = UNDEFINEDNot run on a processor: the instruction does not exist in 64-bit mode, where the probe runs.
Operands
| Operand | Kind | Action |
|---|---|---|
DAA not in 64-bit mode | ||
AL | implicit | read, write |
RFLAGS | implicit | read, write |
Flags
| OF | SF | ZF | AF | PF | CF |
|---|---|---|---|---|---|
| All forms | |||||
| U | M | M | TM | M | TM |
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-258 (DAA)
- 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.