* remove "\r" nonsense
[mascara-docs.git] / i386 / i386.reference / s03_03.htm
blob05f1b96ab4a08dcfaeda3cea73986047078e33a7
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
2 <HTML>
3 <HEAD>
4 <TITLE>80386 Programmer's Reference Manual -- Section 3.3</TITLE>
5 </HEAD>
6 <BODY>
7 <B>up:</B> <A HREF="c03.htm">
8 Chapter 3 -- Applications Instruction Set</A><BR>
9 <B>prev:</B> <A HREF="s03_02.htm">3.2 Binary Arithmetic Instructions</A><BR>
10 <B>next:</B> <A HREF="s03_04.htm">3.4 Logical Instructions</A>
11 <P>
12 <HR>
13 <P>
14 <H1>3.3 Decimal Arithmetic Instructions</H1>
15 Decimal arithmetic is performed by combining the binary arithmetic
16 instructions (already discussed in the prior section) with the decimal
17 arithmetic instructions. The decimal arithmetic instructions are used in one
18 of the following ways:
19 <UL>
20 <LI> To adjust the results of a previous binary arithmetic operation to
21 produce a valid packed or unpacked decimal result.
22 <LI> To adjust the inputs to a subsequent binary arithmetic operation so
23 that the operation will produce a valid packed or unpacked decimal
24 result.
25 </UL>
26 These instructions operate only on the AL or AH registers. Most utilize the
27 AF flag.
29 <H2>3.3.1 Packed BCD Adjustment Instructions</H2>
30 <A HREF="DAA.htm">DAA</A> (Decimal Adjust after Addition)
31 adjusts the result of adding two valid
32 packed decimal operands in AL.
33 <A HREF="DAA.htm">DAA</A> must always follow the addition of two
34 pairs of packed decimal numbers (one digit in each half-byte) to obtain a
35 pair of valid packed decimal digits as results. The carry flag is set if
36 carry was needed.
37 <P>
38 <A HREF="DAS.htm">DAS</A> (Decimal Adjust after Subtraction)
39 adjusts the result of subtracting
40 two valid packed decimal operands in AL.
41 <A HREF="DAS.htm">DAS</A> must always follow the
42 subtraction of one pair of packed decimal numbers (one digit in each half-
43 byte) from another to obtain a pair of valid packed decimal digits as
44 results. The carry flag is set if a borrow was needed.
46 <H2>3.3.2 Unpacked BCD Adjustment Instructions</H2>
47 <A HREF="AAA.htm">AAA</A> (ASCII Adjust after Addition)
48 changes the contents of register AL to a
49 valid unpacked decimal number, and zeros the top 4 bits.
50 <A HREF="AAA.htm">AAA</A> must always
51 follow the addition of two unpacked decimal operands in AL. The carry flag
52 is set and AH is incremented if a carry is necessary.
53 <P>
54 <A HREF="AAS.htm">AAS</A> (ASCII Adjust after Subtraction)
55 changes the contents of register AL to
56 a valid unpacked decimal number, and zeros the top 4 bits.
57 <A HREF="AAS.htm">AAS</A> must always
58 follow the subtraction of one unpacked decimal operand from another in AL.
59 The carry flag is set and AH decremented if a borrow is necessary.
60 <P>
61 <A HREF="AAM.htm">AAM</A> (ASCII Adjust after Multiplication)
62 corrects the result of a
63 multiplication of two valid unpacked decimal numbers.
64 <A HREF="AAM.htm">AAM</A> must always follow
65 the multiplication of two decimal numbers to produce a valid decimal result.
66 The high order digit is left in AH, the low order digit in AL.
67 <P>
68 <A HREF="AAD.htm">AAD</A> (ASCII Adjust before Division)
69 modifies the numerator in AH and AL to
70 prepare for the division of two valid unpacked decimal operands so that the
71 quotient produced by the division will be a valid unpacked decimal number.
72 AH should contain the high-order digit and AL the low-order digit. This
73 instruction adjusts the value and places the result in AL. AH will contain
74 zero.
75 <P>
76 <HR>
77 <P>
78 <B>up:</B> <A HREF="c03.htm">
79 Chapter 3 -- Applications Instruction Set</A><BR>
80 <B>prev:</B> <A HREF="s03_02.htm">3.2 Binary Arithmetic Instructions</A><BR>
81 <B>next:</B> <A HREF="s03_04.htm">3.4 Logical Instructions</A>
82 </BODY>