Skip to content

Instantly share code, notes, and snippets.

@tanayseven
Created July 31, 2012 20:23
Show Gist options
  • Save tanayseven/3220167 to your computer and use it in GitHub Desktop.
Save tanayseven/3220167 to your computer and use it in GitHub Desktop.
program to randomly enter n integers & find the sum of all the numbers using 8086 compatible assembly language
;program to randomly enter n integers & find the sum of all the numbers
INCLUDE io.h
Cr EQU 0ah
Lf EQU 0dh
data SEGMENT
p_n DB cr, lf, 'Enter n: ',0
p_num DB lf, 'Enter a number: ',0
p_sum DB cr, lf, 'The sum is: ',0
tmpstr DW 40 DUP (?)
data ENDS
code SEGMENT
ASSUME cs:code, ds:data
start: mov ax, data
mov ds, ax
;input n1
output p_n
inputs tmpstr, 10
atoi tmpstr
mov dx, ax
;initialize
mov bx, 0
;input iterations
n_ip: output p_num
inputs tmpstr, 10
atoi tmpstr
add bx, ax
dec dx
jnz n_ip
;output sum
output p_sum
itoa tmpstr, bx
output tmpstr
quit: mov al, 00h
mov ah, 4ch
int 21h
code ENDS
END start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment