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

.MODEL	MEDIUM, PASCAL

.CODE	FS_SEG

;**	strlenFS - compute far string length (near call from FS_SEG)
;
;	ENTRY	(psz) = far pointer to nul-terminated string
;	EXIT	(ax)  = length in bytes of string excluding NULL
;

STRLENFS    PROC    NEAR    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
STRLENFS ENDP

END
