summaryrefslogtreecommitdiff
path: root/lib/libc/arch/i386/string/strchr.S
blob: 6d36a589d1923220eac11f1a77ecaa4ed42e28cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*	$OpenBSD: strchr.S,v 1.5 2015/05/14 21:40:37 kettenis Exp $ */
/*
 * Written by J.T. Conklin <jtc@netbsd.org>.
 * Public domain.
 */

#include <machine/asm.h>

STRONG_ALIAS(index, strchr)

ENTRY(strchr)
	movl	4(%esp),%eax
	movb	8(%esp),%cl
	.align 2,0x90
L1:
	movb	(%eax),%dl
	cmpb	%dl,%cl			/* found char??? */
	je 	L2
	incl	%eax
	testb	%dl,%dl			/* null terminator??? */
	jnz	L1
	xorl	%eax,%eax
L2:
	ret