Posted By : Sehrish Kay
Posted On : 1 November 2014
Keywords : 8086 Add Two Numbers, Assembly Language Add 2 Numbers, Assembly Language 8086 Add Two Numbers, Add Two Single Digit Numbers, Add Two Numbers

8086 Assembly Language Program To Add Two Single Digit Numbers

Problem Statement

Add two single digit numbers in 8086 assembly language and display the output. If the total of the number is above 9 it will not show the correct output as the resulting value will be two digit output. So condition for the program to work is the sum should be less than 10 for the display output to be correct. you can check the value in the ax registry or in ans using the debug and the output should be correct.

Expected Output

Sample Code 8086 : Add Two Single Digit Numbers

Sample Code

.model small
.stack 100h
msg1 db "Enter First Decimal Number : $"
msg2 db ,0dh,0ah,"Enter Second Decimal : $"
msg3 db ,0dh,0ah,"SUM of Entered Numbers = $"
num1 db ?;
num2 db ?,;
ans db ?,"$"
main proc 
mov ax,@data            ;initiaize ds
mov ds,ax  
mov dx,offset msg1      ;load and display msg1
mov ah,09
int 21h
mov ah,1h               ;read first initial
int 21h
sub al,30h
mov num1,al 
mov dx,offset msg2      ;load and display msg2
mov ah,9
int 21h
                        ;read second initial
mov ah,1h
int 21h
sub al,30h
mov num2,al
mov dx,offset msg3
mov ah,9                ;load and display msg3
int 21h
mov al,num1             ;add num1 and num2
add al,num2 
add al,30h              ;moves value into ans
mov ans,al
mov dx,offset ans       ;load and display msg3
mov ah,9
int 21h 
                        ;returns control to dos
mov ah, 4ch
int 21h 
main endp
end main                

Run The Program In Emu 8086

Sehrish Kay

I am interested in writing articles on 8086.