Instruction Set
4-4
AAD
ASCII Adjust AX Before Division
AAD
What It Does
AAD converts a two-digit unpacked decimal (BCD) number—ordinarily the dividend of an
unpacked decimal division—to its unsigned binary equivalent.
Syntax
Description
AAD prepares two unpacked BCD digits—the least significant digit in the AL register and
the most significant digit in the AH register—for division by an unpacked BCD digit. The
instruction sets the AL register to AL + (10•AH) and then clears the AH register. The AX
register then equals the binary equivalent of the original unpacked two-digit number.
Operation It Performs
Flag Settings After Instruction
Examples
This example divides a two-digit unpacked decimal number by a one-digit unpacked
decimal number.
Form
Opcode
Description
Clocks
Am186 Am188
AAD
D5 0A
ASCII-adjust AX before division
15
15
AAD
/* convert AX to binary */
AL = (AH * 10) + AL;
AH = 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
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 ?
UDIVIDEND
DW
0409h
; 49 unpacked BCD
UDIVISOR
DB
03h
; 3 unpacked BCD
; divide unpacked decimal numbers (two digit by one digit)
MOV
AX,UDIVIDEND
; AX = 0409h = 49 unpacked BCD
AAD
; AX = 0031h = 49
DIV
UDIVISOR
; AL = 10h = 16, the quotient
; AH = 01h = 1, the remainder
MOV
BL,AH
; save remainder, BL = 01h = 1
AAM
; AX = 0106h = 16 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...