DAA and DAS Instructions 

The DAA (Decimal Adjust after Addition) instruction allows addition of numbers represented in 8-bit packed BCD code. It is used immediately after normal addition instruction operating on BCD codes. This instruction assumes the AL register as the source and the destination, and hence it requires no operand.
The effect of DAS (Decimal Adjust after Subtraction) instruction is similar to that of DAA, except that it is used after a subtraction instruction.

For example in the following program, that NUM1 and NUM2 are decimal numbers coded in BCD format, the result should be 61

DAA Instructions
.MODEL SMALL
.STACK 200
.DATA
NUM1	DB 	27H
NUM2	DB	35H	
.CODE
.STARTUP

	MOV	AL,  NUM1	;load AX with number NUM1
	ADD 	AL,  NUM2	;AL = AL + NUM2 i.e. AL = 5CH = 92 in decimal
	;The expected result is 62 in decimal
	DAA			; AL = 62
.EXIT
END

DAA operation:

For the processor there is no difference between a BCD and a hexadecimal number, all numbers are seen as hexadecimal numbers.
After performing an addition and the result is saved in the AL register, conversion to decimal is carried out as follows:
  • if the digit in the lower four nibbles of AL is greater than 10 (decimal),
  • then subtract 10 and
  • add 1 to the digit in the higher four nibbles of AL.
  • Example:

    Suppose that the result obtained after adding 27 to 35, is 5CH. To convert this to the value that we would expect after a decimal addition, the DAA instruction is used.

  • assume result = AL = 5CH
  • digit in the low four nibbles of AL = C = 12
  • then 12 - 10 = 2
  • hence keep the 2 and
  • add 1 to the digit in the higher four nibbles of AL 5 + 1 = 6
  • The result is thus: 62
  • The DAS instruction works in a similar fashion after a SUB instruction.