;PROADD_1--G6_3
;**********************************************************
data	 segment		;define data segment
  ary		dw	1,2,3,4,5,6,7,8,9,10
  count		dw	10
  sum		dw	?
data	 ends
;**********************************************************
code	 segment		;defint code segment
;----------------------------------------------------------
main	proc	far		;main part of program

	assume cs:code,ds:data

start:				;starting execution address
	push	ds
	sub	ax,ax
	push	ax
;
	mov	ax,data
	mov	ds,ax
;	
	call	near ptr proadd
	ret
main	endp			;end of main part of prog.
;----------------------------------------------------------
proadd	proc	near		;define subprocedure
	push	ax		;save the registers
	push	cx
	push	si
	lea	si,ary		;put addr of ary in si
	mov	cx,count	;put count in cx
	xor	ax,ax		;clear ax
next:	add	ax,[si]		;add the elements of the
	add	si,2		;  array to AX
	loop	next		    
	mov	sum,ax		;store the result in sum
	pop	si		;restore the registers
	pop	cx
	pop	ax
	ret			;return
proadd	endp			;end subprocedure
;----------------------------------------------------------
code    ends			;end of code segment
;**********************************************************
	end	start		;end assembly
