NetBSD/sys/lib/libkern/arch/x86_64/strlen.S
keihan b8702f530b netbsd.org -> NetBSD.org
This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean".  Thanks for the patiance, and sorry for all the commits.
2003-12-04 13:57:30 +00:00

22 lines
564 B
ArmAsm

/*
* Written by J.T. Conklin <jtc@NetBSD.org>.
* Public domain.
* Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS)
RCSID("$NetBSD: strlen.S,v 1.2 2003/12/04 13:57:31 keihan Exp $")
#endif
ENTRY(strlen)
cld /* set search forward */
xorl %eax,%eax /* set search for null terminator */
movq $-1,%rcx /* set search for lots of characters */
repne /* search! */
scasb
notq %rcx /* get length by taking complement */
leaq -1(%rcx),%rax /* and subtracting one */
ret