Microcomputer principle, additive correction AAA algorithm

AAA(Ascii Adjust After add) is an Ascii code plus an adjustment instruction to adjust the value of AL, which is the sum of two ASCII code bytes. The adjustment rules are as follows:

1. If the lower four bits of AL are greater than 9 or the flag bit AF= 1, then AH=AH+ 1, AL=AL+6, and the juxtaposition of AF and CF is 1, otherwise only AF and CF are set to 0;

2. Clear the upper four digits of AL.

MOV AX, 19H

Add aluminum, 07H

After execution, AL=20H. At this time, although the lower four bits of AL do not exceed 9, the flag bit AF= 1, that is, the lower four bits of AL are carried forward to the upper four bits. Therefore, after executing the AAA instruction, AH=AH+ 1, AL=AL+6, tie AF and CF to 1, and then clear the upper four bits of AL. Results: