xref: /netbsd-src/lib/libc/arch/i386/string/index.S (revision 954b7961567b96e7f5bdebca46dec63f6369e771)
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("$Id: index.S,v 1.7 1995/04/28 22:54:11 jtc Exp $")
10#endif
11
12#ifdef STRCHR
13ENTRY(strchr)
14#else
15ENTRY(index)
16#endif
17	pushl	%ebx
18	movl	8(%esp),%eax
19	movb	12(%esp),%cl
20	.align 2,0x90
21L1:
22	movb	(%eax),%bl
23	cmpb	%bl,%cl			/* found char??? */
24	je 	L2
25	incl	%eax
26	testb	%bl,%bl			/* null terminator??? */
27	jnz	L1
28	xorl	%eax,%eax
29L2:
30	popl	%ebx
31	ret
32