Write an assembly program that prompts the user for two numb

Write an assembly program that prompts the user for two numbers and prints the sum. Sample Screen Shot: Enter Number 1: 2 Enter Number 2: 3 The sum of 2 and 3 is 5 Submit the following by uploading them using ICollege/D2L in the respective assignment drop box: lastname1.s lastname2.s Make sure to include comments in your assembly file including your name, assignment number, date, sections number. Follow the program standards as presented in your book. Pay more attention to code comments and consistent indentation.

Solution

section   .text
global _start
  

_start:  
mov ax,@data ;initiaizeing data segment
mov ds,ax
mov dx,offset msg1 ;Display Message 1
mov ah,09
int 21h
mov ah,1h ;Read the first number
int 21h
sub al,30h
mov num1,al
mov dx,offset msg2 ;Display Message 2
mov ah,9
int 21h
;Read the first number
mov ah,1h
int 21h
sub al,30h
mov num2,al
mov dx,offset msg3
mov ah,9 ;Display Message 3
int 21h
mov al,num1 ;add number 1 and number 2
add al,num2
add al,30h ;moves value into ans
mov ans,al
mov dx,offset ans ;Display Message 3
mov ah,9
int 21h
;returns control
mov ah, 4ch
int 21h
  
section .data

msg1 db \"Enter First Number : $\"
msg2 db ,0dh,0ah,\"Enter Second Number: $\"
msg3 db \"The sum is:\", 0xA,0xD
segment .bss
sum resb 1

 Write an assembly program that prompts the user for two numbers and prints the sum. Sample Screen Shot: Enter Number 1: 2 Enter Number 2: 3 The sum of 2 and 3

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site