;PROADD_2--G6_4
;***********************************************************
prog_seg segment 
		
	org	100h

	assume cs:prog_seg,ds:prog_seg,ss:prog_seg

main	proc	near
;
	mov	table,offset ary;put the addresses
	mov	table+2,offset count;  of ary,count and sum
	mov	table+4,offset sum  ;    in parameter table
	mov	bx,offset table	;put addr of table in BX
	call    proadd		;call proadd
	int	20h
main	endp
;----------------------------------------------------------
proadd	proc	near		;define subprocedure
	push	ax		;save registers
	push	cx
	push	si
	push	di
	mov	si,[bx]		;get the addr of array,
	mov	di,[bx+2]	;  the value of count,
	mov	cx,[di]	 	;    and the addr of
	mov	di,[bx+4]	;      result
	xor	ax,ax		;clear AX
next:	add	ax,[si]		;add the elements
	add	si,2		;  of the array
	loop	next		;    to AX
	mov	[di],ax		;return result
	pop	di		;restore registers
	pop	si
	pop	cx
	pop	ax
	ret			;return
proadd	endp			;end subprocedure
;----------------------------------------------------------
  ary	dw	1,2,3,4,5,6,7,8,9,10
				;reserve 10 words for ary
  count	dw	10		;  and 1 word for count
  sum	dw	?		;    and 1 word for sum
  table	dw	3 dup(?)	;reserve 3 words for
				;  parameter addresses
;----------------------------------------------------------
prog_seg ends
;**********************************************************
	end	main
