Why Do We Add 6 to AL in BCD Arithmetic?
One of the most common questions when studying the Intel 8086 and BCD (Binary-Coded Decimal) arithmetic is:
The answer lies in the difference between binary numbers and BCD numbers.
BCD vs Binary Representation
A single BCD digit can represent only decimal values from 0 to 9.
| System | Range | Binary Values |
|---|---|---|
| BCD Digit | 0 – 9 | 0000 to 1001 |
| 4-bit Binary | 0 – 15 | 0000 to 1111 |
Therefore, the following binary values are invalid BCD digits:
1010 = 10
1011 = 11
1100 = 12
1101 = 13
1110 = 14
1111 = 15
The Mathematical Reason
In BCD, after digit 9 comes decimal 10. However, in binary, the next value after 9 is still represented within the same nibble.
The correction value is obtained from:
16 - 10 = 6
Since a 4-bit nibble naturally rolls over at 16, adding 6 (06H) forces the binary result into a valid BCD format and generates the proper decimal carry.
If a BCD digit becomes greater than 9, add 06H.
Example 1: 8 + 5
Step 1: Binary Addition
1000 (8)
+ 0101 (5)
-------
1101 (13)
The result 1101 equals decimal 13, which is not a valid
single BCD digit.
Step 2: Add 06H
1101
+ 0110
-------
1 0011
The carry becomes the tens digit and 0011 becomes the units digit.
0001 0011 = BCD 13
0001 0011.
Example 2: 9 + 8
Binary Addition
1001 (9)
+ 1000 (8)
-------
10001 (17)
Since the decimal value exceeds 9, a BCD correction is required.
After decimal adjustment, the result becomes:
0001 0111
Which represents:
17
How the DAA Instruction Uses This Rule
The Intel 8086 provides the DAA
(Decimal Adjust after Addition) instruction to perform this correction automatically.
MOV AL,08H
ADD AL,05H
DAA
| Step | AL Value |
|---|---|
| After ADD | 0DH |
| After DAA | 13H |
The DAA instruction detects that the lower nibble exceeds 9 and automatically adds 06H to produce a valid packed BCD result.
Visual Explanation
Key Takeaway
A 4-bit binary digit can represent values from 0 to 15, but a BCD digit can represent only 0 to 9. Whenever a BCD digit exceeds 9, adding 06H converts the invalid binary value into a valid BCD representation while generating the correct decimal carry.
Formula:
Correction = 16 - 10 = 6
This is the fundamental reason why the Intel 8086 DAA instruction adds 06H to AL during BCD adjustment.