Home | History | Annotate | Download | only in string
      1 /*	$OpenBSD: strlen.S,v 1.3 2005/08/07 11:30:38 espie Exp $ */
      2 /*
      3  * Written by J.T. Conklin <jtc (at) netbsd.org>.
      4  * Public domain.
      5  */
      6 
      7 #include <machine/asm.h>
      8 
      9 ENTRY(strlen)
     10 	pushl	%edi
     11 	movl	8(%esp),%edi		/* string address */
     12 	cld				/* set search forward */
     13 	xorl	%eax,%eax		/* set search for null terminator */
     14 	movl	$-1,%ecx		/* set search for lots of characters */
     15 	repne				/* search! */
     16 	scasb
     17 	notl	%ecx			/* get length by taking	complement */
     18 	leal	-1(%ecx),%eax		/* and subtracting one */
     19 	popl	%edi
     20 	ret
     21