AAD: ASCII Adjust AX Before Division

For information about interpreting this page, see the help page.
Opcode and MnemonicEncoding16 bit Mode32 bit Mode64 bit ModeDescription
D5 0A
ZOValidValidInvalidASCII adjust AX before division.
D5 ib
AAD imm8
IValidValidInvalidASCII adjust AX before division to number base imm8.


ZONone (implicitly 10)


The AAD instruction prepares a BCD number for division.

This instruction will not be useful unless it is immediately followed by a DIV (Unsigned Divide) instruction. Before executing either this instruction or the DIV (Unsigned Divide) one, one should ensure that DX is 0.

Traditionally, this instruction is "ASCII Adjust Before Division". This would lead one to believe that it works on ASCII digits (030h (0) through 039h (9)), however this would be incorrect. This instruction actually operates on BCD digits (00h (0) through 09h (9)).

This instruction implicitly operates on the AH and AL registers.

Due to a quirk of history, this instruction encodes the base of the result in the instruction (the second byte). As such, it is possible to have this instruction work on other bases through an immediate 8 bit operand. Such methods are not guaranteed to be supported by your assembler, and in such situations, one must encode the instruction directly.

This instruction is not valid in 64 bit mode, and if encountered, the processor will raise a #UD exception.


This pseudo-code uses C# syntax. A list of the types used is available here.
public void AAD(byte imm8)
  AL = (AL + (AH * imm8)) & 0xFF;
  AH = 0;
The operation of the AAD instruction


  1. According to the source code for Bochs' (/cpu/bcd.cc), this instruction actually performs the operation on the AX register, not AL. This is currently untested.

Flags Affected

CF (carry flag)
PF (parity flag)
Set based on the resulting value in AL.
AF (auxiliary flag)
ZF (zero flag)
Set based on the resulting value in AL.
SF (sign flag)
Set based on the resulting value in AL.
OF (overflow flag)


Protected Mode

If the LOCK prefix is used.

Real-Address Mode

Same exceptions as protected mode.

Virtual-8086 Mode

Same exceptions as protected mode.

Compatibility Mode

Same exceptions as protected mode.

Long Mode

If in 64 bit mode.