The algorithm performed by the ASCII Adjust After Addition instruction is documented as always clearing the upper nibble of AL. However, the current implementation does not do so.
IF 64-Bit Mode
THEN
#UD;
ELSE
IF ((AL AND 0FH) > 9) or (AF = 1)
THEN
AX := AX + 106H;
AF := 1;
CF := 1;
ELSE
AF := 0;
CF := 0;
FI;
AL := AL AND 0FH;
FI;
This can be fixed by adding the bitwise and in the aaa implementation.
The algorithm performed by the ASCII Adjust After Addition instruction is documented as always clearing the upper nibble of AL. However, the current implementation does not do so.
From https://www.felixcloutier.com/x86/aaa:
This can be fixed by adding the bitwise and in the
aaa
implementation.