
Instruction Set
4-2
AAA
ASCII Adjust AL After Addition
AAA
What It Does
AAA converts an 8-bit unsigned binary number that is the sum of two unpacked decimal
(BCD) numbers to its unpacked decimal equivalent.
Syntax
Description
Use the AAA instruction after an ADD or ADC instruction that leaves a byte result in the
AL register. The lower nibbles of the operands of the ADD or ADC instruction should be in
the range 0–9 (BCD digits). The AAA instruction adjusts the AL register to contain the
correct decimal digit result. If the addition produced a decimal carry, AAA increments the
AH register and sets the Carry and Auxiliary-Carry Flags (CF and AF). If there is no decimal
carry, AAA clears CF and AF and leaves the AH register unchanged. AAA sets the top
nibble of the AL register to 0.
Operation It Performs
Flag Settings After Instruction
Form
Opcode
Description
Clocks
Am186 Am188
AAA
37
ASCII-adjust AL after addition
8
8
AAA
if (((AL = AL & 0x0F) > 9) || (AF == 1))
/* AL is not yet in BCD format */
/* (note high nibble of AL is cleared either way) */
{
/* convert AL to decimal and unpack */
AL = (AL + 6) & 0x0F;
AH = AH + 1;
/* set carry flags */
CF = AF = 1;
}
else
/* clear carry flags */
CF = AF = 0;
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
Processor Status
Flags Register
reserved
OF DF
IF TF SF ZF
AF
PF
CF
? = undefined; – = unchanged
?
–
–
–
?
? res
res ? res
AF=1 if carry or borrow to low nibble
AF=0 otherwise
CF=1 for carry or borrow to high-order bit
CF=0 otherwise
Содержание Am186 Series
Страница 1: ...Am186 and Am188 Family Instruction Set Manual February 1997...
Страница 10: ...Table of Contents x...
Страница 18: ...Programming 1 8...
Страница 40: ...Instruction Set Listing 3 14...