include	clib.inc
include	iost.inc

	public	oread

_TEXT	SEGMENT

oread	PROC
	les	bx,STDI
	mov	dx,STDI.ios_i
	add	bx,dx
	mov	cx,STDI.ios_c
	sub	cx,dx
	cmp	cx,ax
	jb	oread_01
	mov	ax,cx
    oread_00:
	test	ax,ax
	ret
    oread_01:
	push	ax
	call	ofread
	pop	ax
	jz	oread_02
	mov	cx,STDI.ios_c
	sub	cx,STDI.ios_i
	cmp	cx,ax
	jae	oread
    oread_02:
	xor	ax,ax
	jmp	oread_00
oread	ENDP

_TEXT	ENDS

	END
