IA-32 Assembly Language Reference Manual

ASCII Adjust after Subtraction (aas)

aas

Operation

ASCII-adjust AL -> AL

Description

Use aas only after executing the form of an add instruction that stores a two-BCD-digit byte result in the AL register. aas 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 aas instruction with:

or %al, 0x30

Table 2-9 shows how aas handles a carry.

Table 2-9 How aas Handles 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 a sub instruction that stores a two-BCD-digit byte

aas