;       SCCSID = @(#)istrlen.asm	6.2 91/01/14
SCCSID      equ     "@(#)istrlen.asm	6.2 91/01/14"
;
;	IBM/Microsoft Confidential
;
;	Copyright (c) IBM Corporation 1987, 1990
;	Copyright (c) Microsoft Corporation 1987, 1990
;
;	All Rights Reserved

;***    fstrlen.asm - compute string length

ifdef MEDIUM_MODEL
.MODEL MEDIUM, PASCAL
else
.MODEL SMALL, PASCAL
endif

.286P

ifdef MEDIUM_MODEL
.CODE _TEXT
else
.CODE
endif


;**     istrlen - compute far string length (init)
;
;       ENTRY   (psz) = far pointer to nul-terminated string
;       EXIT    (ax) = lenght in bytes of string excluding NUL
;

ifdef MEDIUM_MODEL
ISTRLEN PROC    FAR     USES DI,     psz:DWORD
else
ISTRLEN PROC            USES DI,     psz:DWORD
endif


	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 

ISTRLEN ENDP

END
