How to use 8086 assembly language to add any two numbers(16 - bits)? Our teacher
ID: 3769332 • Letter: H
Question
How to use 8086 assembly language to add any two numbers(16 - bits)?
Our teacher wants us to follow the steps:
1. get num1 from the user (input will be string data, use int 80h)
a) display prompt b) capture result
2. get num2 from the user (input will be string data, use int 80h)
a) display prompt b) capture result
3. convert num1 to a numeric value (this step requires converting string data into numeric value)
4. convert num1 to a numeric value (this step requires converting string data into numeric value)
5. add num1 and num2
6. convert sum to string data (ASCII character codes for the digits)
7. display the result (use int 80h)
a) display message b) display sum as character data
The final output should look like this:
Enter the first number: " "
Enther the second number: " "
The sum of the two numbers is:" "
Please do not write it too complicated because I just began to learn this. Appreciate your help.
Explanation / Answer
Here is your program to add two numbers using assembly language in 8086 assembly language.
.model small
.data
a db "Enter the first number$"
b db "Enter the second number$"
c db "The sum is: $"
d db 00h
.code
start:
mov ax,@data
mov ds,ax
mov dx,offset a
mov ah,09h
int 21h
mov ah,01h
int 21h
mov bh,al
mov ah,01h
int 21h
mov bl,al
mov dx,offset b
mov ah,09h
int 21h
mov ah,01h
int 21h
mov ch,al
mov ah,01h
int 21h
mov cl,al
add al,bl
mov ah,00h
aaa
add bh,ah
add bh,ch
mov d,al
mov al,bh
mov ah,00h
aaa
mov bx,ax
add bx,3030h
mov dx,offset c
mov ah,09h
int 21h
mov dl,bh
mov ah,02h
int 21h
mov dl,bl
mov ah,02h
int 21h
mov dl,d
add dl,30h
mov ah,02h
int 21h
end start
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.