1998-02-22 10:21:32 +03:00
|
|
|
/*
|
|
|
|
* Written by J.T. Conklin <jtc@netbsd.org>.
|
|
|
|
* Public domain.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <machine/asm.h>
|
|
|
|
|
|
|
|
#if defined(LIBC_SCCS)
|
1999-08-23 13:07:35 +04:00
|
|
|
RCSID("$NetBSD: rindex.S,v 1.2 1999/08/23 09:07:35 kleink Exp $")
|
1998-02-22 10:21:32 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef STRRCHR
|
|
|
|
ENTRY(strrchr)
|
|
|
|
#else
|
|
|
|
ENTRY(rindex)
|
|
|
|
#endif
|
|
|
|
pushl %ebx
|
|
|
|
movl 8(%esp),%edx
|
|
|
|
movb 12(%esp),%cl
|
|
|
|
xorl %eax,%eax /* init pointer to null */
|
1999-08-23 13:07:35 +04:00
|
|
|
_ALIGN_TEXT,0x90
|
1998-02-22 10:21:32 +03:00
|
|
|
L1:
|
|
|
|
movb (%edx),%bl
|
|
|
|
cmpb %bl,%cl
|
|
|
|
jne L2
|
|
|
|
movl %edx,%eax
|
|
|
|
L2:
|
|
|
|
incl %edx
|
|
|
|
testb %bl,%bl /* null terminator??? */
|
|
|
|
jnz L1
|
|
|
|
popl %ebx
|
|
|
|
ret
|