How to use 8086 assembly language to add any two numbers(16 - bits)? 1. get num1
ID: 3771440 • Letter: H
Question
How to use 8086 assembly language to add any two numbers(16 - bits)?
1. get num1 from the user (input will be string data, use int 80h)
2. get num2 from the user (input will be string data, use int 80h)
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)
Important note: Step 3 and step 4 requires to convert string input into numeric value and numeric values back to string data; It is very important to have the code for the conversions.
mov cx, convert: sub al,48 ;to covert to int sub al,48 to covert to int mov bl,al jin bl will be the digit read mov ax, cx mul ten mov bh,0 add ax,bx mov cx,ax ten ax will store the old result multiplied by 10Explanation / Answer
.model small .stack 100h .data 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 ?,"$" .code 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
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.