# `aam`

[x86-64 Documentation](https://asm-editor.specy.app/documentation/x86.md) › [Instructions](https://asm-editor.specy.app/documentation/x86/instruction.md)

Web page: https://asm-editor.specy.app/documentation/x86/instruction/aam

**ASCII adjust ax after multiply**

Category: Arithmetic

Divides al by 10, or by an imm8 base, leaving the quotient in ah and the remainder in al.

8086 and later · Not available in 64-bit mode

[Intel's reference: AAM](https://intel.github.io/SDM/instruction/AAM.html)

## Flags

| Flag | Effect |
| --- | --- |
| CF | undefined (do not rely on it) |
| PF | depends on the result |
| AF | undefined (do not rely on it) |
| ZF | depends on the result |
| SF | depends on the result |
| DF | not changed |
| OF | undefined (do not rely on it) |

## Forms

- `aam`
- `aam imm8`

## Operands

- `imm8`: An 8-bit immediate, `-128` to `255`. Instructions that sign-extend it to a wider operand interpret the byte as `-128` to `127`; shift counts do not use this sign extension.

## Description

There are also packed BCD instructions `DAA` and `DAS`: see
[`DAA`](https://asm-editor.specy.app/documentation/x86/instruction/daa.md).

- `AAA` (ASCII Adjust After Addition) should be used after a
one-byte `ADD` instruction whose destination was the `AL`
register: by means of examining the value in the low nibble of
`AL` and also the auxiliary carry flag `AF`, it determines
whether the addition has overflowed, and adjusts it (and sets
the carry flag) if so. You can add long BCD strings together
by doing `ADD`/`AAA` on the low digits, then doing
`ADC`/`AAA` on each subsequent digit.

- `AAS` (ASCII Adjust AL After Subtraction) works similarly to
`AAA`, but is for use after `SUB` instructions rather than
`ADD`.

- `AAM` (ASCII Adjust AX After Multiply) is for use after you
have multiplied two decimal digits together and left the result
in `AL`: it divides `AL` by ten and stores the quotient in
`AH`, leaving the remainder in `AL`. The divisor 10 can be
changed by specifying an operand to the instruction: a particularly
handy use of this is `AAM 16`, causing the two nibbles in `AL`
to be separated into `AH` and `AL`.

- `AAD` (ASCII Adjust AX Before Division) performs the inverse
operation to `AAM`: it multiplies `AH` by ten, adds it to
`AL`, and sets `AH` to zero. Again, the multiplier 10 can
be changed.
