IA-32 Assembly Language Reference Manual

ASCII Adjust after Addition (aaa)

aaa
Operation

ASCII-adjust AL -> AL

Description

You use aaa only after executing the form of an add instruction that stores a two-BCD-digit byte result in the AL register. aaa then adjusts AL to contain the correct decimal result. The top nibble of AL is set to 0. To convert AL to an ASCII result, follow the aaa instruction with:

or %al, 0x30

Table 2-8 shows how aaa handles a carry.

Table 2-8 aaa Handling a Carry

Carry 

Action 

decimal carry 

AH + 1; CF and AF set to 1 

no decimal carry 

AH unchanged; CF and AF cleared to 0 

Example

Adjust the AL register to contain the correct decimal result after an add instruction that stores a two-BCD-digit byte.

aaa