ASCII Adjust AX After Multiplication

Encoding

EncodingOperand
zoNone (implicitly 10)
iimm8

Description

The AAM instruction converts the result of a multiplication of two BCD digits to a valid 2-digit BCD number.

Traditionally, this instruction is 'ASCII Adjust After Multiplication'. This would lead one to believe that it works on ASCII digits (30h ("0") through 39h ('9')), however, this is incorrect. This instruction actually operates on binary coded decimal (BCD) digits (00h through 09h).

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 Long Mode.

Operation

public void AAM(U8 imm8)
{
    AH = AL / imm8;
    AL = AL % imm8;
}

Flags Affected

CF (carry flag)
Undefined.
PF (parity flag)
Set according to the result.
AF (auxiliary flag)
Undefined.
ZF (zero flag)
Set according to the result.
SF (sign flag)
Set according to the result.
OF (overflow flag)
Undefined.

Exceptions

Real-Address Mode

#DE
  • If an immediate value of 0 is used.
#UD
  • If the LOCK prefix is used.

Virtual-8086 Mode

#DE
  • If an immediate value of 0 is used.
#UD
  • If the LOCK prefix is used.

Protected Mode

#DE
  • If an immediate value of 0 is used.
#UD
  • If the LOCK prefix is used.

Compatibility Mode

#DE
  • If an immediate value of 0 is used.
#UD
  • If the LOCK prefix is used.

Long Mode

#UD
  • If in Long Mode.