how to add two numbers with the help of AAA instruction.

Use Of AAA instruction

The AAA instruction is only useful when it follows an ADD instruction that adds (binary addition) two unpacked BCD values and stores a byte result in the AL register. The AAA instruction then adjusts the contents of the AL register to contain the correct 1-digit unpacked BCD result.


.model small
.stack 100h
.data
msg1 db "Enter first number:$"
msg2 db 10d,"Enter second number:$"
msg3 db 10d,"Addition is:$"
.code
mov ax,@data
mov ds,ax

mov ah,09h

mov dx,offset msg1
int 21h

mov ah,01h
int 21h
mov cl,al

mov ah,09h
mov dx,offset msg2
int 21h

mov ah,01h
int 21h
mov ch,al

add ch,cl

mov al,ch
mov ah,00h

AAA

mov ch,ah
mov cl,al

mov ah,09h
mov dx,offset msg3
int 21h

mov dl,ch
add dl,30h
mov ah,2
int 21h
mov dl,cl
add dl,30h
mov ah,2
int 21h
mov ah,4ch
int 21h
end

Output:

how to  add two numbers with the help of AAA instruction.




Comments