Write a NASM program that does the following:
1) Asks the user to enter three numbers (each is a byte) A,B, and C
2) Adds up the numbers and stores the sum in variable D
3) Outputs the sum
NASM PROGRAM!
INCLUDE io.h
Cr EQU 0ah
Lf EQU 0dh
data SEGMENT
p_a DB cr, lf, 'Enter a: ',0
p_b DB lf, 'Enter b: ',0
p_c DB lf, 'Enter c: ',0
p_sum DB cr, lf, 'The sum is: ',0
p_avg DB cr, lf, 'The avg is: ',0
tmpstr DW 40 DUP (?)
data ENDS
code SEGMENT
ASSUME cs:code, ds:data
start: mov ax, data
mov ds, ax
;input a
output p_a
inputs tmpstr, 10
atoi tmpstr
mov dx, ax
;input b
output p_b
inputs tmpstr, 10
atoi tmpstr
add dx, ax
;input c
output p_c
inputs tmpstr, 10
atoi tmpstr
add dx, ax
;find and print sum
output p_sum
mov ax, dx
itoa tmpstr, ax
output tmpstr
;find and print average
output p_avg
cwd
mov cx, 3
idiv cx
itoa tmpstr, ax
output tmpstr
quit: mov al, 00h
mov ah, 4ch
int 21h
code ENDS
END start
Get Answers For Free
Most questions answered within 1 hours.