80386 Programmer's Reference Manual -- Opcode AAS

AAS -- ASCII Adjust AL after Subtraction

OpcodeInstructionClocks DescriptionExample
3Faas 4 ASCII adjust AL after subtractionaas


IF (AL AND 0FH) > 9 OR AF = 1
   AL := AL - 6;
   AL := AL AND 0FH;
   AH := AH - 1;
   AF := 1;
   CF := 1;
   CF := 0;
   AF := 0;


Execute AAS only after a SUB instruction that leaves the byte result in the AL register. The lower nibbles of the operands of the SUB instruction must have been in the range 0 through 9 (BCD digits). In this case, AAS adjusts AL so it contains the correct decimal digit result. If the subtraction produced a decimal carry, the AH register is decremented, and the carry and auxiliary carry flags are set to 1. If no decimal carry occurred, the carry and auxiliary carry flags are set to 0, and AH is unchanged. In either case, AL is left with its top nibble set to 0. To convert AL to an ASCII result, follow the AAS with OR AL, 30H.

Flags Affected

AF and CF as described above; OF, SF, ZF, and PF are undefined

Protected Mode Exceptions


Real Address Mode Exceptions


Virtual 8086 Mode Exceptions


[Home Page dell'ITIS "Fermi"] [80386 Programmer's Reference Manual Index] [Previous] [Next]