Learn Assembly in 10 Days! Final Day (10.)

If you would like to go back to the previous day, have a look at: https://www.pcocular.com/2021/05/17/learn-assembly-in-10-days-day-9/

Assembly language

This is the final (10.) day of learning Assembly language.

AAA Instruction

AAA after an ADD (that stores a two-BCD-digit byte result in the AL register) adjusts AL to contain the correct decimal result. The top nibble of AL is set to zero. To convert AL to an ASCII result, follow the AAA with: or %al, 0x30 .

In other words it converts the result of the addition of two valid unpacked BCD digits to a valid 2-digit BCD number and takes the AL register as its implicit operand.

Two operands of the addition must have its lower 4 bits contain a number in the range from 0-9. AAA then adjust AL so that it contains a correct BCD digit. If the addition produce carry then AH register is incremented and the carry and auxiliary flags are set to 1. If the addition did not produce a decimal carry, CF and AF are cleared to zero and AH is not changed. In both cases the higher four bits of AL are cleared to zero.

AAA will adjust the result of the two ASCII characters that were in the range from 30h (“0”) to 39h (“9”). This is because the lower 4 bits of those character fall in the range of 0-9. The result of addition is not a ASCII character but it is a BCD digit.


MOV AH, 0 ; Clear AH for MSD
MOV AL, 6 ; BCD 6 in AL
ADD AL, 5 ; Add BCD 5 to digit in AL
AAA       ; AH = 1, AL = 1 representing BCD 11.

Furter information:

ASCII table: https://upload.wikimedia.org/wikipedia/commons/1/1b/ASCII-Table-wide.svg

ASCII converter: https://www.branah.com/ascii-converter

Binary to Decimal to Hexadecimal Converter: https://www.mathsisfun.com/binary-decimal-hexadecimal-converter.html

Online Assembly Compiler: https://www.tutorialspoint.com/compile_assembly_online.php

8086 FLAG register: https://www.answers.com/Q/Explain_8086_flag_register

Thats all, if you want to learn Assembly language in 10 Days. 🙂

CONGRATULATIONS! You have finished the 10 day course! Wel done! 🙂

For more info about computer programming, please read PC Ocular website articles!

Benkő Attila is a Hungarian senior software developer, independent researcher and author of many computer science related papers.

Leave a Reply