include	clib.inc
include	dos.inc

PPROC	findfirst, file:DPTR, fblk:DPTR, attr:word
	push	ds
	mov	ah,2Fh
	int	21h
	push	es
	push	bx
	mov	ah,1Ah
	MLDS	dx,fblk
	int	21h
	mov	ah,4Eh
	mov	cx,attr
	MLDS	dx,file
	int	21h
	pushf
	pop	cx
	xchg	ax,bx
	mov	ah,1Ah
	pop	dx
	pop	ds
	int	21h
	push	cx
	popf
	pop	ds
	jc	findfirst_err
	xor	ax,ax
    findfirst_end:
	ret
    findfirst_err:
	call	@dosmaper
	mov	ax,-1
	jmp	findfirst_end
PEND	findfirst

PPROC	findnext, @@FB:DPTR
	push	ds
	mov	ah,2Fh
	int	21h
	push	es
	push	bx
	mov	ah,1Ah
	MLDS	dx,@@FB
	int	21h
	mov	ah,4Fh
	int	21h
	pushf
	pop	cx
	xchg	ax,bx
	mov	ah,1Ah
	pop	dx
	pop	ds
	int	21h
	push	cx
	popf
	pop	ds
	jc	findnext_err
	xor	ax,ax
    findnext_end:
	ret
    findnext_err:
	call	@dosmaper
	mov	ax,-1
	jmp	findnext_end
PEND	findnext

	END
