Decimal Adjust After Addition (DAA) in x86: How It Converts Binary Sums to Valid BCD

Decimal Adjust After Addition (DAA) in x86: How It Converts Binary Sums to Valid BCD

Verified Sources
Nov 3, 2026

The x86 instruction DAA performs a decimal-correction on the 8-bit sum in AL after adding two unsigned 8-bit values that represent (packed) BCD digits. Conceptually, DAA ensures that the low nibble (bits 0–3) and high nibble (bits 4–7) each become valid decimal digits (0–9) in hexadecimal encoding (i.e., BCD format).2

A typical interpretation is:

  • Treat the original operands as packed BCD:
    • low nibble = ones digit (0–9)
    • high nibble = tens digit (0–9)
  • After an ordinary binary addition, some intermediate digit nibbles may exceed 9.
  • DAA conditionally adds:
    • 6 to fix the low nibble
    • 0x60 to fix the high nibble
  • It also updates the digit-carry-related flags:
    • AF tracks whether a carry occurred from bit 3 to 4 during the low-nibble correction decision
    • CF tracks whether the overall decimal correction produced a carry beyond the two-digit BCD range

The pseudocode you provided matches the canonical DAA correction logic: it first checks the low nibble and prior AF state; then it checks the high nibble and the prior CF state.2

Footnotes

  1. Intel® 64 and IA-32 Architectures Software Developer’s Manual — DAA instruction description (DAA adjusts AL for BCD using AF and +0x06+0x06 rule). https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html - See the instruction reference entry for DAA (decimal adjust after addition). ↩ ↩2

  2. Intel® 64 and IA-32 Architectures Software Developer’s Manual — DAA second phase rule (high nibble check using AL>0x9FAL>0x9F or CF=1 and adding 0x600x60). https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html - See DAA (decimal adjust after addition) for +0x60+0x60 and CF behavior. ↩ ↩2

Key idea: DAA performs two independent “digit validations”

DAA essentially enforces BCD constraints for each nibble after a binary addition:

  • Low nibble correction (add 0x06) happens when the ones digit is not valid BCD or when the previous half-digit carry implies it should be corrected.2
  • High nibble correction (add 0x60) happens when the tens digit is not valid BCD or when the overall carry implies it should be corrected.2

This produces a packed BCD result in AL (two decimal digits) for many typical uses involving BCD addition.

Footnotes

  1. Intel® 64 and IA-32 Architectures Software Developer’s Manual — DAA instruction description (DAA adjusts AL for BCD using AF and +0x06+0x06 rule). https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html - See the instruction reference entry for DAA (decimal adjust after addition). ↩ ↩2

  2. Intel® 64 and IA-32 Architectures Software Developer’s Manual — DAA second phase rule (high nibble check using AL>0x9FAL>0x9F or CF=1 and adding 0x600x60). https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html - See DAA (decimal adjust after addition) for +0x60+0x60 and CF behavior. ↩ ↩2

Why “add 6” and “add 0x60”?

If a nibble holds an invalid value between 10 and 15, it must be reduced by 10 (in decimal sense) while keeping BCD encoding aligned. The standard trick is:

  • After adding two BCD digits, if the low nibble exceeds 9, then adding 6 adjusts it so the resulting nibble maps to the correct decimal digit.
  • Because packed BCD stores tens in the high nibble, the corresponding correction is 0x60 (which is 6 shifted left by 4).

This is exactly what the DAA micro-logic performs: it implements the decimal carry correction for base-10 digits using base-16 arithmetic.2

Footnotes

  1. Intel® 64 and IA-32 Architectures Software Developer’s Manual — DAA instruction description (DAA adjusts AL for BCD using AF and +0x06+0x06 rule). https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html - See the instruction reference entry for DAA (decimal adjust after addition). ↩

  2. Intel® 64 and IA-32 Architectures Software Developer’s Manual — DAA second phase rule (high nibble check using AL>0x9FAL>0x9F or CF=1 and adding 0x600x60). https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html - See DAA (decimal adjust after addition) for +0x60+0x60 and CF behavior. ↩

What the DAA pseudocode does (line-by-line)

  1. 1
    Step 1

    Evaluate (AL&0x0F)>9(AL \& 0x0F) > 9 or use the prior AF as an indicator that a half-digit carry occurred. If true, the ones digit is corrected by adding 0x060x06.

  2. 2
    Step 2

    If the condition is true, set AL←AL+0x06AL \leftarrow AL + 0x06 and set AF to 11. Otherwise, set AF to 00.

  3. 3
    Step 3

    Evaluate whether AL>0x9FAL > 0x9F (meaning the high nibble is effectively > 9) or whether the prior CF indicates a carry that requires decimal correction.

  4. 4
    Step 4

    If the condition is true, set AL←AL+0x60AL \leftarrow AL + 0x60 and set CF to 11. Otherwise, set CF to 00.

Relationship to BCD addition correctness

Let the original sum in AL represent “two decimal digits” in packed BCD encoding. After a raw binary addition, each nibble may not reflect a valid digit 0–9. DAA fixes this by:

  • correcting the ones digit using +0x06 when necessary
  • correcting the tens digit using +0x60 when necessary
  • setting flags so that the correction reflects decimal carry behavior

In other words, DAA converts a binary sum of BCD-encoded operands into a valid packed BCD result, while propagating the proper decimal-carry information via AF/CF.2

Footnotes

  1. Intel® 64 and IA-32 Architectures Software Developer’s Manual — DAA instruction description (DAA adjusts AL for BCD using AF and +0x06+0x06 rule). https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html - See the instruction reference entry for DAA (decimal adjust after addition). ↩

  2. Intel® 64 and IA-32 Architectures Software Developer’s Manual — DAA second phase rule (high nibble check using AL>0x9FAL>0x9F or CF=1 and adding 0x600x60). https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html - See DAA (decimal adjust after addition) for +0x60+0x60 and CF behavior. ↩

Mental model

Think of each nibble as a separate base-10 digit. DAA checks whether each digit is still in [0,9][0,9]. If not, it adds 66 (ones) or 0x600x60 (tens) to bring it back into BCD-valid range.

DAA is not a generic decimal conversion for arbitrary binary integers

DAA assumes the inputs represent packed BCD digits. If AL contains an arbitrary binary sum that is not derived from valid BCD operands, the correction rules may not produce a meaningful decimal result.

DAA correction decisions (mapping to nibble validity)

DAA uses the low-nibble check first (AF-related), then a high-nibble/carry check (CF-related).

Common interpretations and edge cases

Quick self-check on DAA

1 / 4
Question · Term

What does DAA ensure about AL?

Click to reveal
Answer · Definition

That AL becomes valid packed BCD: both nibbles represent decimal digits (0–9), after a preceding addition of BCD-encoded operands.

Footnotes

  1. Intel® 64 and IA-32 Architectures Software Developer’s Manual — DAA instruction description (DAA adjusts AL for BCD using AF and +0x06+0x06 rule). https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html - See the instruction reference entry for DAA (decimal adjust after addition). ↩

DAA correction lifecycle (after an addition)

Compute raw binary sum

1

Operands are added normally; result is in AL with binary carry behavior."

Adjust low nibble

2

If ones digit invalid (or AF indicates half-carry), add 0x06; set AF accordingly."

Adjust high nibble

3

If tens digit invalid (or CF indicates carry), add 0x60; set CF accordingly."

Final corrected packed BCD in AL

4

AL now encodes the correct two-digit packed BCD result."

Knowledge Check

Question 1 of 4
Q1Single choice

Which constant does DAA add to correct an invalid low nibble (ones digit) after addition?