1993-10-07 03:17:24 +03:00
|
|
|
/*
|
1995-04-29 02:53:59 +04:00
|
|
|
* Written by J.T. Conklin <jtc@netbsd.org>.
|
|
|
|
* Public domain.
|
1993-10-07 03:17:24 +03:00
|
|
|
*/
|
|
|
|
|
1994-03-12 04:39:55 +03:00
|
|
|
#include <machine/asm.h>
|
|
|
|
|
1993-10-21 04:39:55 +03:00
|
|
|
#if defined(LIBC_SCCS)
|
1999-08-23 12:45:09 +04:00
|
|
|
RCSID("$NetBSD: rindex.S,v 1.10 1999/08/23 08:45:10 kleink Exp $")
|
1993-10-21 04:39:55 +03:00
|
|
|
#endif
|
1993-10-07 03:17:24 +03:00
|
|
|
|
1993-12-09 01:10:14 +03:00
|
|
|
#ifdef STRRCHR
|
|
|
|
ENTRY(strrchr)
|
|
|
|
#else
|
1993-10-07 03:17:24 +03:00
|
|
|
ENTRY(rindex)
|
1993-12-09 01:10:14 +03:00
|
|
|
#endif
|
1993-10-07 03:17:24 +03:00
|
|
|
pushl %ebx
|
|
|
|
movl 8(%esp),%edx
|
|
|
|
movb 12(%esp),%cl
|
|
|
|
xorl %eax,%eax /* init pointer to null */
|
1999-08-23 12:45:09 +04:00
|
|
|
_ALIGN_TEXT,0x90
|
1993-10-07 03:17:24 +03:00
|
|
|
L1:
|
|
|
|
movb (%edx),%bl
|
|
|
|
cmpb %bl,%cl
|
|
|
|
jne L2
|
|
|
|
movl %edx,%eax
|
1993-10-21 04:48:14 +03:00
|
|
|
L2:
|
1993-10-07 03:17:24 +03:00
|
|
|
incl %edx
|
|
|
|
testb %bl,%bl /* null terminator??? */
|
1994-02-14 23:05:52 +03:00
|
|
|
jnz L1
|
1993-10-07 03:17:24 +03:00
|
|
|
popl %ebx
|
|
|
|
ret
|