Intel and compatable CPU's Programming Information Intel SSE MMX2 KNI documentation

AMD 64 Bit & Opteron resource on this site

Intel Itanium 64 Bit processor

CPU Heat Dissipation Table

Intel 80386 Reference Programmer's Manual

Our Partners: up: Chapter 3 -- Applications Instruction Set
prev: 3.2 Binary Arithmetic Instructions
next: 3.4 Logical Instructions

# 3.3 Decimal Arithmetic Instructions

Decimal arithmetic is performed by combining the binary arithmetic instructions (already discussed in the prior section) with the decimal arithmetic instructions. The decimal arithmetic instructions are used in one of the following ways:
• To adjust the results of a previous binary arithmetic operation to produce a valid packed or unpacked decimal result.
• To adjust the inputs to a subsequent binary arithmetic operation so that the operation will produce a valid packed or unpacked decimal result.
These instructions operate only on the AL or AH registers. Most utilize the AF flag.

## 3.3.1 Packed BCD Adjustment Instructions

DAA (Decimal Adjust after Addition) adjusts the result of adding two valid packed decimal operands in AL. DAA must always follow the addition of two pairs of packed decimal numbers (one digit in each half-byte) to obtain a pair of valid packed decimal digits as results. The carry flag is set if carry was needed.

DAS (Decimal Adjust after Subtraction) adjusts the result of subtracting two valid packed decimal operands in AL. DAS must always follow the subtraction of one pair of packed decimal numbers (one digit in each half- byte) from another to obtain a pair of valid packed decimal digits as results. The carry flag is set if a borrow was needed.

## 3.3.2 Unpacked BCD Adjustment Instructions

AAA (ASCII Adjust after Addition) changes the contents of register AL to a valid unpacked decimal number, and zeros the top 4 bits. AAA must always follow the addition of two unpacked decimal operands in AL. The carry flag is set and AH is incremented if a carry is necessary.

AAS (ASCII Adjust after Subtraction) changes the contents of register AL to a valid unpacked decimal number, and zeros the top 4 bits. AAS must always follow the subtraction of one unpacked decimal operand from another in AL. The carry flag is set and AH decremented if a borrow is necessary.

AAM (ASCII Adjust after Multiplication) corrects the result of a multiplication of two valid unpacked decimal numbers. AAM must always follow the multiplication of two decimal numbers to produce a valid decimal result. The high order digit is left in AH, the low order digit in AL.

AAD (ASCII Adjust before Division) modifies the numerator in AH and AL to prepare for the division of two valid unpacked decimal operands so that the quotient produced by the division will be a valid unpacked decimal number. AH should contain the high-order digit and AL the low-order digit. This instruction adjusts the value and places the result in AL. AH will contain zero.

up: Chapter 3 -- Applications Instruction Set
prev: 3.2 Binary Arithmetic Instructions
next: 3.4 Logical Instructions
{"ft_lang_label":"__label__en","ft_lang_prob":0.8083647,"math_prob":0.8865159,"size":2577,"snap":"2022-27-2022-33","text_gpt3_token_len":537,"char_repetition_ratio":0.16284493,"word_repetition_ratio":0.22062351,"special_character_ratio":0.19790454,"punctuation_ratio":0.07592191,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9899429,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-08-08T21:59:44Z\",\"WARC-Record-ID\":\"<urn:uuid:8371a263-31c2-40fd-917b-3d8080c36e54>\",\"Content-Length\":\"8778\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:a19a7f2f-93a0-47c2-89c0-2a31e2df84b3>\",\"WARC-Concurrent-To\":\"<urn:uuid:3535cabc-7ba9-42d5-98ea-8f6d3379943d>\",\"WARC-IP-Address\":\"185.154.54.10\",\"WARC-Target-URI\":\"http://intel80386.com/386htm/s03_03.htm\",\"WARC-Payload-Digest\":\"sha1:U33NE7Z7GQNOWPBPB5RMOLXLDGZZD72E\",\"WARC-Block-Digest\":\"sha1:OVZQB7W2LXDZ5YYH7K4HDR2ZD3PZBQR6\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-33/CC-MAIN-2022-33_segments_1659882570879.1_warc_CC-MAIN-20220808213349-20220809003349-00662.warc.gz\"}"}