;       SCCSID = @(#)fstrlen.asm	6.1 90/11/18
;	SCCSID = @(#)fstrlen.asm      13.2 90/01/25
;***	fstrlen.asm - compute string length (using far pointer)
;
;	fstrlen - near call from _TEXT

ifdef MEDIUM_MODEL
.MODEL	MEDIUM, PASCAL

.CODE	_TEXT
else
.MODEL	SMALL, PASCAL

.CODE
endif

;**	fstrlen - compute far string length
;
;	ENTRY	(psz) = far pointer to nul-terminated string
;	EXIT	(ax)  = length in bytes of string excluding NULL
;

FSTRLEN PROC	USES DI,    psz:DWORD

	les	di,psz		; (es:di) point to string
	xor	ax,ax		; (ax) = nul to look for
	mov	cx,0FFFFh	; (cx) = max # of bytes to look through
	cld
    repne   scasb		; find nul
	xchg	ax,cx		; (ax) = - (count of bytes incl NUL + 1)
	neg	ax		; (ax) = count of bytes incl NUL + 1
	dec	ax		; (ax) = count of bytes incl NUL
	dec	ax		; (ax) = count of bytes

	ret
FSTRLEN ENDP

END
