	.file	"strlen.s"
/*
 * $Copyright:	$
 * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
 * Sequent Computer Systems, Inc.   All rights reserved.
 *  
 * This software is furnished under a license and may be used
 * only in accordance with the terms of that license and with the
 * inclusion of the above copyright notice.   This software may not
 * be provided or otherwise made available to, or used by, any
 * other person.  No title to or ownership of the software is
 * hereby transferred.
 *
 */

/*	Copyright (c) 1984 AT&T	*/
/*	All Rights Reserved	*/

/*	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T	*/
/*	The copyright notice above does not evidence any	*/
/*	actual or intended publication of such source code.	*/

	.ident	"@(#)$Header: strlen.s 1.4 89/10/10 $"

/* Fast assembler language version of the following C-program	*/
/*			strlen					*/
/* which represents the `standard' for the C-library.		*/

/*
 * Returns the number of
 * non-NULL bytes in string argument.
 */

/*
 *	int
 *	strlen(s)
 *	register char *s;
 *	{
 *		register char *s0 = s + 1;
 *	
 *		while (*s++ != '\0')
 *			;
 *		return (s - s0);
 *	}
 */

#include "sys.s"

ENTRY(strlen)
	movl	%edi,%edx		/ save %edi
	movl	SPARG0,%edi		/ %edi = string
	xorl	%eax,%eax		/ match null byte
	movl	$-1,%ecx		/ count = -1
	repnz ; scab			/ scan forward till null byte
	incl	%ecx			/Dhip re-decrements.
	movl	%ecx,%eax
	notl	%eax			/ %eax = len (twos compliment rule)
	movl	%edx,%edi		/ restore %edi
	ret
