Opcode | Encoding | 16-bit | 32-bit | 64-bit | Description |
---|---|---|---|---|---|
3F AAS | zo | Valid | Valid | Invalid | ASCII adjust AX after subtraction. |
Encoding
Encoding | Operand |
---|---|
zo | None |
Description
The AAS
instruction converts the result of a subtraction of two BCD digits to a valid 2-digit BCD number.
An "unpacked" BCD number is one where each byte contains a single digit. In contrast, a packed BCD number is one where each byte contains two digits – one in each nibble. The DAS
(Decimal Adjust AL
After Subtraction) instruction handles that case.
Traditionally, this instruction is 'ASCII Adjust After Subtraction'. 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
).
This instruction is not valid in Long Mode.
Operation
public void AAS(U8 imm8)
{
if ((AL & 0xF) > 9 || EFLAGS.AF)
AX -= 0x106;
AL &= 0xF;
}
Flags Affected
CF
(carry flag)- Set if an adjustment is made. Cleared otherwise.
PF
(parity flag)- Undefined.
AF
(auxiliary flag)- Set if an adjustment is made. Cleared otherwise.
ZF
(zero flag)- Undefined.
SF
(sign flag)- Undefined.
OF
(overflow flag)- Undefined.
Exceptions
Exception | Mode | Cause of Exception | |||
---|---|---|---|---|---|
Real Mode | Virtual 8086 | Protected and Compatibility | Long Mode | ||
#UD | X | X | X | If the LOCK prefix is used. | |
X | If in Long Mode. |