Created
July 31, 2012 20:21
-
-
Save tanayseven/3220139 to your computer and use it in GitHub Desktop.
program to find the sum of 3 numbers and also its average using 8086 compatible assembly language
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;program to find the sum of 3 numbers and also its average | |
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 |
I think I have done this using MASM long back. But you might have to try which MASM works with this.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hello, can u please tell me which assembly editor can i use with this code