
Instruction Set
4-6
AAM
ASCII Adjust AL After Multiplication
AAM
What It Does
AAM converts an 8-bit unsigned binary number—ordinarily the product of two unpacked
decimal (BCD) numbers—to its unpacked decimal equivalent.
Syntax
Description
Use AAM only after executing the MUL instruction between two unpacked BCD operands
with the result in the AX register. Because the result is 99 or less, it resides entirely in the
AL register. AAM unpacks the AL result by dividing AL by 10, leaving the quotient (most
significant digit) in AH and the remainder (least significant digit) in AL.
Operation It Performs
Flag Settings After Instruction
Examples
This example multiplies two unpacked decimal digits.
Form
Opcode
Description
Clocks
Am186 Am188
AAM
D4 0A
ASCII-adjust AL after multiplication
19
19
AAM
/* convert AL to decimal */
AH = AL / 10;
AL = AL % 10;
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
SF=1 if result is 0 or positive
SF=0 if result is negative
ZF=1 if result equal to 0
ZF=0 if result not equal to 0
PF=1 if low byte of result has even number of set bits
PF=0 otherwise
?
–
–
–
res ? res
res ?
UMULTIPLICAND
DB
07h
; 7 unpacked BCD
UMULTIPLIER
DB
06h
; 6 unpacked BCD
; multiply unpacked decimal numbers
MOV
AL,UMULTIPLICAND
; AL = 07h = 7 unpacked BCD
MUL
UMULTIPLIER
; AL = 2Ah = 42
AAM
; AX = 0402h = 42 unpacked BCD
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...