AAD prepares for the division below, which consists of a decimal number of the AL and AH two single BCD codes.
1. AAD (adjust except)
5.2 The instruction is used to adjust the value of the Register AH and Al before division, it is a decimal value of the single BCD code in the two registers, and its adjustment rules are as follows:
Al←ah*10+al,ah←0
Affected flag bits: PF, SF, and ZF (AF, CF, and of all are undefined)
movmov BL, 10DAAD ; ah=0, al=52h DIV BL ; ah=2 (remainder), al=5 (quotient)
2. DAA (adjustment plus 10)
The directive is used to adjust the value of Al, which is the result of two compressed BCD codes that are operated by the instruction add or the ADC. The compressed BCD code is a byte that holds two BCD codes, the lower four bits and the high four bits are all a BCD code. The adjustment rules are as follows:
- If AL's lower four bits are greater than 9, or af=1, then, al=al+06h, collocated af=1;
- If the high four bits of AL are greater than 9, or cf=1, then, al=al+60h, and cf=1;
- If none of the above two points is true, clear the flag bit AF and CF.
After adjustment, the value of Al is still compressed BCD code, namely: two compressed BCD code added, and adjusted, the result is the compression type BCD code.
Affected flag bits: AF, CF, PF, SF, and ZF (of no definition)
movmovADD AL, BL ; DAA; after adjustment, al=72h, this is the compression type BCD code, also has: 43+29=72
3, DAS (adjustment minus 10)
The directive is also used to adjust the value of Al, and Al is the result of an instruction sub or SBB operation of two compressed BCD codes. The adjustment rules are as follows:
- If AL's lower four bits are greater than 9, or af=1, then, al=al-06h, collocated af=1;
- If the high four bits of AL are greater than 9, or cf=1, then, al=al-60h, and cf=1;
- If none of the above two points is true, clear the flag bit AF and CF.
After adjustment, the value of Al is still compressed BCD code, namely: two compression BCD code subtraction, and adjusted, the result is the compression type BCD code.
Affected flag bits: AF, CF, PF, SF, and ZF (of no definition)
movmovSUB AL, BL ; Al=1ah, which is not a compressed BCD code because the low four bit ' A ' is not a BCD code DAS ;
1
Compilation--aad,daa,das Detailed