xref: /netbsd/lib/libc/arch/i386/string/rindex.S (revision bf9ec67e)
1/*
2 * Written by J.T. Conklin <jtc@netbsd.org>.
3 * Public domain.
4 */
5
6#include <machine/asm.h>
7
8#if defined(LIBC_SCCS)
9	RCSID("$NetBSD: rindex.S,v 1.10 1999/08/23 08:45:10 kleink Exp $")
10#endif
11
12#ifdef STRRCHR
13ENTRY(strrchr)
14#else
15ENTRY(rindex)
16#endif
17	pushl	%ebx
18	movl	8(%esp),%edx
19	movb	12(%esp),%cl
20	xorl	%eax,%eax		/* init pointer to null */
21	_ALIGN_TEXT,0x90
22L1:
23	movb	(%edx),%bl
24	cmpb	%bl,%cl
25	jne	L2
26	movl	%edx,%eax
27L2:
28	incl	%edx
29	testb	%bl,%bl			/* null terminator??? */
30	jnz	L1
31	popl	%ebx
32	ret
33