Instruction
AAS
Corrects AL after subtracting two unpacked BCD digits: if the low digit exceeds 9 or AF is set, subtracts 6 from AX and 1 from AH; not in 64-bit mode.
- Extensions
- Forms
- 1 (1 Legacy)
- Data
- Intel XED v2026.08.23
AAS is AAA for subtraction: after a SUB of one unpacked BCD digit from another, it corrects AL and borrows from AH. When the low four bits of AL are above 9, or AF says that the subtraction borrowed from them, it subtracts 6 from AL and 1 from AH, which Intel’s pseudocode writes as 106h taken from AX, and sets AF and CF; otherwise it clears both. The high four bits of AL are cleared either way, and OF, SF, ZF and PF are undefined. With ASCII digits, ‘3’ minus ‘5’ (33h minus 35h) leaves FEh with AF set, and AAS with AH = 0 gives AX = FF08h and CF set: 8 in AL and a borrow of 1 in AH, which is -10 + 8 = -2.
Which AL is corrected
AMD’s Volume 3 tests whether AL as a whole is above 9, where Intel’s manual, the Operation section and AMD’s own text for AAA test the low four bits. The two differ for an AL above 9 whose low digit is 9 or less with AF clear, such as 30h, left by a SUB of an unpacked digit from an ASCII one: by Intel’s rule AAS leaves AH alone and clears CF. The difference of two digits of the same kind, both ASCII or both unpacked, is 00h to 09h or has AF set, and there the two rules agree.
Not in 64-bit mode
Opcode 3F raises #UD in 64-bit mode, so the fixture has no case for AAS:
the probe runs there and lists the form as not run. GNU as 2.44 and
Clang 23 refuse aas in 64-bit code, and GCC 14 and Clang 23 have no
intrinsic for it. AMD’s Zen 5 guide lists AAS as microcoded, without a
latency.
Forms
| Instruction | Encoding | Requires |
|---|---|---|
AAS not in 64-bit mode
AAS | 3F | Base instruction set |
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
a = ax
if (a & 0xF) > 9 or af: # the low digit borrowed
a -= 0x106 # AL - 6, its borrow from AH, and AH - 1
af = cf = 1
else:
af = cf = 0
ax = a & 0xFF0F # AL keeps its low four bits
of = sf = zf = pf = UNDEFINEDNot run on a processor: the instruction does not exist in 64-bit mode, where the probe runs.
Operands
| Operand | Kind | Action |
|---|---|---|
AAS not in 64-bit mode | ||
AL | implicit | read, write |
AH | implicit | read, write |
RFLAGS | implicit | read, write |
Flags
| OF | SF | ZF | AF | PF | CF |
|---|---|---|---|---|---|
| All forms | |||||
| U | U | U | TM | U | M |
CPUID and processors
Each form belongs to an XED ISA set. A form can be used when the processor reports every CPUID bit of one of its ISA set's alternatives.
| ISA set | CPUID | Processors |
|---|---|---|
I86 | No CPUID bit: part of the base instruction set. | Every x86-64 processor in XED’s model and Zen 3 to Zen 6 |
More General-purpose instructions
Sources
- Intel XED v2026.08.23 (commit
0bcb6237345c): forms, encodings, operands, flags, exception classes, attributes, ISA sets, CPUID bits and chip model. - The CPU data of x86-64.net: Zen 3 to Zen 6, from GCC’s
-marchfeature sets and AMD’s Processor Programming References, which the page of each processor cites. - Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-093, September 2026): Volume 2A, page 3-7 (AAS)
- AMD64 Architecture Programmer's Manual, Volume 3: General-Purpose and System Instructions (24594, rev. 3.39, October 2026)
- Software Optimization Guide for the AMD Zen5 Microarchitecture (58455, rev. 1.00, August 2024), Wayback Machine copy of AMD's ZIP
The tables are derived from Intel XED, Copyright Intel Corporation, licensed under the Apache License 2.0; x86-64.net converted and reformatted them. The text is our own.