Code | Mnemonic | Description |
---|---|---|
D5 0A | AAD | ASCII adjust AX before division |
D5 ib | (no mnemonic) | Adjust AX before division to number base imm8 |
Adjusts two unpacked BCD digits (the least-significant digit in the AL register and the most-significant digit in the AH register) so that a division operation performed on the result will yield a correct unpacked BCD value. The AAD instruction is only useful when it precedes a DIV instruction that divides (binary division) the adjusted value in the AX register by an unpacked BCD value.
The AAD instruction sets the value in the AL register to (AL + (10 * AH)), and then clears the AH register to 00H. The value in the AX register is then equal to the binary equivalent of the original unpacked two-digit (base 10) number in registers AH and AL.
The generalized version of this instruction allows adjustment of two unpacked digits of any number base (see the "Operation" section below), by setting the imm8 byte to the selected number base (for example, 08H for octal, 0AH for decimal, or 0CH for base 12 numbers). The AAD mnemonic is interpreted by all assemblers to mean adjust ASCII (base 10) values. To adjust values in another number base, the instruction must be hand coded in machine code (D5 imm8).
Operands | Bytes | Clocks | |
---|---|---|---|
2 | 10 | NP |
ID | unaffected | DF | unaffected |
---|---|---|---|
VIP | unaffected | IF | unaffected |
VIF | unaffected | TF | unaffected |
AC | unaffected | SF | sets according to the result |
VM | unaffected | ZF | sets according to the result |
RF | unaffected | AF | undefined |
NT | unaffected | PF | sets according to the result |
IOPL | unaffected | CF | undefined |
OF | undefined |