strlen.S (559B)
1 /* $Id: //depot/blt/lib/strlen.S#1 $ */ 2 3 /* $OpenBSD: strlen.S,v 1.2 1996/09/27 06:47:51 mickey Exp $ */ 4 5 /* 6 * Written by J.T. Conklin <jtc@netbsd.org>. 7 * Public domain. 8 */ 9 10 #include <i386/asm.h> 11 12 FUNCTION (strlen) 13 pushl %edi 14 movl 8(%esp),%edi /* string address */ 15 cld /* set search forward */ 16 xorl %eax,%eax /* set search for null terminator */ 17 movl $-1,%ecx /* set search for lots of characters */ 18 repne /* search! */ 19 scasb 20 notl %ecx /* get length by taking complement */ 21 leal -1(%ecx),%eax /* and subtracting one */ 22 popl %edi 23 ret