Aad and Daa Inst Set

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 12

INSTRUCTION SET

- AAA AND DAA

BY
HAMSINI SHANKAR
INAYAT KAZI
RUSHIL TIKU
AAA- ASCII ADJUST AFTER ADDITION

 Is used after addition to adjust the value of the


result to BCD.
 The AAA instruction adjusts the contents of the
AL register to contain the correct 1-digit
unpacked BCD result.
 In this case the higher nibble of AL is cleared
 Syntax
AAA : AL ← (AL corrected for ASCII addition)

 FLAGS Affected
AF (Auxiliary Flag)
CF (Carry Flag)
 The logic used behind the AAA instruction

If
low nibble of AL > 9 or AF=1
AL = AL + 6
AH = AH + 1
AF = 1
CF =1
Else
AF= 0
CF=0
EXAMPLE OF AAA INST.

1. MOV AX, 15 ; AH = 00, AL = 0Fh


AAA ; AH = 01, AL = 05
RET
DAA- DECIMAL ADJUST
AFTER ADDITION
 Changes the content of AL to valid packed
decimal digits.

 The daa instruction is used to adjust the content


of the AL register after that register is used to
perform the addition of two packed BCDs.
SYNTAX

 DAA : AL←(AL corrected for BCD addition)

The logic for this instruction is


 If
( lower nibble of AL > 9 or Af=1)
AL ← AL + 6; AF ← 1
If(upper nibble of AL>9 or CF=1)
AL←AL + 60H; CF ← CF+ 1
FLAG STATUS
 The flags affected are AF (Auxiliary), PF
(parity), CF(carry) & ZF(zero)

 The flag not-defined is OF


EXAMPLE 1
mov al,38h ;packed decimal "38“
add al,45h ;add packed decimal "45“
daa ; AL = 7Dh -> 83h (with CF clear = 83 packed
decimal)
 
AL CF AF
; after addition 7Dh clear clear
; daa 83h clear set (because al AND 0Fh > 9)
; daa 83h clear set (al !> 99h && CF clear)
EXAMPLE 2
mov al,88h ;packed decimal "88“
add al,74h ;add packed decimal "74“
daa ;AL = 0FCh -> 62h (with CF set = 162 packed
decimal)
 
AL CF AF
; after addition 0FCh clear clear
; daa (al+6) 02h set set (because al AND
0Fh > 9)
; daa (al+60h) 62h set set (because CF set)
REFERENCES
 MICROPROCESSOR PROGRAMMING X86
THANK YOU

You might also like