include	clib.inc
include	wsub.inc
include	fblk.inc

PPROC	wsfblk, wsub:dword, index:word
	mov	ax,index
	les	bx,wsub
	cmp	es:[bx],ax
	jle	wsfblk_err
	les	bx,es:[bx.ws_fcb]
	shl	ax,2
	add	bx,ax
	mov	dx,es:[bx+2]
	mov	bx,es:[bx]	; return DX:BX, ES:BX - fblk
	mov	es,dx		;        DX:AX - fblk.name
	mov	ax,bx		;        CX - fblk.flag
	add	ax,fb_name	;        ZF - clear
	mov	cx,es:[bx]
    wsfblk_end:
	ret
    wsfblk_err:
	xor	ax,ax
	cwd
	jmp	wsfblk_end
PEND	wsfblk

	END
