3-143
INSTRUCTION SET REFERENCE
DAADecimal Adjust AL after Addition
Description
This instruction adjusts the sum of two packed BCD values to create a packed BCD result. The
AL register is the implied source and destination operand. The DAA instruction is only useful
when it follows an ADD instruction that adds (binary addition) two 2-digit, packed BCD values
and stores a byte result in the AL register. The DAA instruction then adjusts the contents of the
AL register to contain the correct 2-digit, packed BCD result. If a decimal carry is detected, the
CF and AF flags are set accordingly.
Operation
IF (((AL AND 0FH) > 9) or AF = 1)
THEN
AL
<
AL + 6;
CF
<
CF OR CarryFromLastAddition; (* CF OR carry from AL
<
AL + 6 *)
AF
<
1;
ELSE
AF
<
0;
FI;
IF ((AL AND F0H) > 90H) or CF = 1)
THEN
AL
<
AL + 60H;
CF
<
1;
ELSE
CF
<
0;
FI;
Example
ADD AL, BLBefore: AL=79H BL=35H EFLAGS(OSZAPC)=XXXXXX
After: AL=AEH BL=35H EFLAGS(0SZAPC)=110000
DAA
Before: AL=2EH BL=35H EFLAGS(OSZAPC)=110000
After: AL=04H BL=35H EFLAGS(0SZAPC)=X00101
Opcode
Instruction
Description
27
DAA
Decimal adjust AL after addition