Skip to content
Henk-Jan Lebbink edited this page Jun 4, 2026 · 14 revisions

DAS — Decimal Adjust AL After Subtraction

Opcode Instruction Op/ En 64-Bit Mode Compat/ Leg Mode Description
2F DAS ZO Invalid Valid Decimal adjust AL after subtraction.

Instruction Operand Encoding

Op/En Operand 1 Operand 2 Operand 3 Operand 4
ZO N/A N/A N/A N/A

Description

Adjusts the result of the subtraction of two packed BCD values to create a packed BCD result. The AL register is the implied source and destination operand. The DAS instruction is only useful when it follows a SUB instruction that subtracts (binary subtraction) one 2-digit, packed BCD value from another and stores a byte result in the AL register. The DAS instruction then adjusts the contents of the AL register to contain the correct 2-digit, packed BCD result. If a decimal borrow 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_ALAL;
        old_CFCF;
        CF0;
        IF (((AL AND 0FH) > 9) or AF = 1)
        THEN
                ALAL - 6;
                CFold_CF or (Borrow from ALAL6);
                AF1;
            ELSE
                AF0;
        FI;
        IF ((old_AL > 99H) or (old_CF = 1))
            THEN
                ALAL60H;
                CF1;
        FI;
FI;

Example

SUB
        AL, BL
                Before: AL = 35H, BL = 47H, EFLAGS(OSZAPC) = XXXXXX
                After: AL = EEH, BL = 47H, EFLAGS(0SZAPC) = 010111
DAA
                Before: AL = EEH, BL = 47H, EFLAGS(OSZAPC) = 010111
                After: AL = 88H, BL = 47H, EFLAGS(0SZAPC) = X10111

Flags Affected

The CF and AF flags are set if the adjustment of the value results in a decimal borrow in either digit of the result (see the “Operation” section above). The SF, ZF, and PF flags are set according to the result. The OF flag is undefined.

Protected Mode Exceptions

#UD If the LOCK prefix is used.

Real-Address Mode Exceptions

#UD If the LOCK prefix is used.

Virtual-8086 Mode Exceptions

#UD If the LOCK prefix is used.

Compatibility Mode Exceptions

#UD If the LOCK prefix is used.

64-Bit Mode Exceptions

#UD If in 64-bit mode.


Source: Intel® 64 and IA-32 Architectures Software Developer's Manual, Combined Volumes (Order Number 325462-091US, March 2026)
Generated: 7-6-2026

Clone this wiki locally