xref: /netbsd-src/lib/libc/arch/i386/string/index.S (revision 5e4c038a45edbc7d63b7c2daa76e29f88b64a4e3)
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: index.S,v 1.10 2000/08/07 14:46:52 ad Exp $")
10#endif
11
12#ifdef STRCHR
13ENTRY(strchr)
14#else
15ENTRY(index)
16#endif
17	movl	4(%esp),%eax
18	movb	8(%esp),%cl
19	_ALIGN_TEXT,0x90
20L1:
21	movb	(%eax),%dl
22	cmpb	%dl,%cl			/* found char??? */
23	je 	L2
24	incl	%eax
25	testb	%dl,%dl			/* null terminator??? */
26	jnz	L1
27	xorl	%eax,%eax
28L2:
29	ret
30