beautypg.com

Daa-decimal adjust al after addition, Daa—decimal adjust al after addition – Intel 253666-024US User Manual

Page 303

background image

Vol. 2A 3-257

INSTRUCTION SET REFERENCE, A-M

DAA—Decimal Adjust AL after Addition

DAA—Decimal Adjust AL after Addition

Description

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.
This instruction executes as described above in compatibility mode and legacy mode.
It is not valid in 64-bit mode.

Operation

IF 64-Bit Mode

THEN

#UD;

ELSE

old_AL ← AL;

old_CF ← CF;

CF ← 0;

IF (((AL AND 0FH)

>

9) or AF

=

1)

THEN

AL ← AL

+

6;

CF ← old_CF or (Carry from AL ← AL

+

6);

AF ← 1;

ELSE

AF

← 0;

FI;
IF ((old_AL

>

99H) or (old_CF

=

1))

THEN

AL ← AL

+

60H;

CF

← 1;

ELSE

CF ← 0;

FI;

FI;

Opcode

Instruction

64-Bit

Mode

Compat/

Leg Mode

Description

27

DAA

Invalid

Valid

Decimal adjust AL after addition.