.model small
.code
		org	100h

start:
		jmp	init
cur:		dw	0
path:		db	'array'
num:		db	'1.dat',0				
_int_17:	cmp	ah,0
		jne	_iret
		
		push	bx
		push	si
		mov	si,offset buffer
		mov	bx,word ptr cs:cur
		
		cmp	bx,60000
		ja	_go
			
		mov	byte ptr cs:[si][bx],al
		inc	bx
		mov	word ptr cs:cur,bx

_go:		mov	ax,0

		pop	si	
		pop	bx
_iret:		iret
vector_17:
         	db	0eah
old_17	        dw	?,?

_int_5:
		push	ax
		push	bx
		push	cx
		push	dx

		push	ds


		push	cs
		pop	ds

		mov	ax,word ptr cur
		cmp	ax,0
		je	exit

		mov	ah,3ch	
		mov	dx,offset path
		mov	cx,0
		int	21h

		mov	bx,ax
		mov	dx,offset buffer
		mov	cx,word ptr cur
		mov	ah,40h
		int	21h

		mov	ah,3eh
		int	21h
			
		mov	al,byte ptr num
		inc	al
		mov	byte ptr num,al

		mov	word ptr cur,0
exit:
		pop	ds
		pop	dx
		pop	cx
		pop	bx
		pop	ax
		iret

buffer:		db	60000  dup(?);

init:   	
		mov	ax,3517h
		int	21h
		mov	old_17,bx
		mov	old_17+2,es
		mov	ax,2517h
		mov	dx,offset _int_17
		int	21h
		mov	ax,2505h
		mov	dx,offset _int_5
		int	21h
		
		mov 	dx,offset init
		int 	27h

end	start


