
Instruction Set
4-8
AAS
ASCII Adjust AL After Subtraction
AAS
What It Does
AAS converts an 8-bit unsigned binary number that is the difference of two unpacked
decimal (BCD) numbers to its unpacked decimal equivalent.
Syntax
Description
Use AAS only after a SUB or SBB instruction that leaves the byte result in AL. The lower
nibbles of the operands of the SUB or SBB instruction must be in the range 0–9 (BCD).
AAS adjusts AL so that it contains the correct decimal result. If the subtraction produced a
decimal borrow, AAS decrements AH and sets CF and AF. If there is no decimal borrow,
AAS clears CF and AF and leaves AH unchanged. AAS sets the top nibble of AL to 0.
Operation It Performs
Flag Settings After Instruction
Form
Opcode
Description
Clocks
Am186 Am188
AAS
3F
ASCII-adjust AL after subtraction
7
7
AAS
if (((AL = AL & 0x0F) > 9) || (AF == 1))
/* AL is not yet decimal */
/* (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
Summary of Contents for Am186 Series
Page 1: ...Am186 and Am188 Family Instruction Set Manual February 1997...
Page 10: ...Table of Contents x...
Page 18: ...Programming 1 8...
Page 40: ...Instruction Set Listing 3 14...