4.4BSD snapshot (revision 8.1)
[unix-history] / usr / src / lib / libc / mips / string / strlen.s
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell.
*
* %sccs.include.redist.c%
*/
#include <machine/machAsmDefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
ASMSTR("@(#)strlen.s 8.1 (Berkeley) %G%")
#endif /* LIBC_SCCS and not lint */
LEAF(strlen)
addu v1, a0, 1
1:
lb v0, 0(a0) # get byte from string
addu a0, a0, 1 # increment pointer
bne v0, zero, 1b # continue if not end
subu v0, a0, v1 # compute length - 1 for '\0' char
j ra
END(strlen)