xref: /openbsd-src/lib/libc/arch/i386/string/strchr.S (revision ea6088e7d368d53c49ebfdf4520275cec2f78f5b)
1*ea6088e7Sguenther/*	$OpenBSD: strchr.S,v 1.8 2017/11/29 05:13:57 guenther Exp $ */
25b859c19Sderaadt/*
35b859c19Sderaadt * Written by J.T. Conklin <jtc@netbsd.org>.
45b859c19Sderaadt * Public domain.
55b859c19Sderaadt */
65b859c19Sderaadt
7*ea6088e7Sguenther#include "DEFS.h"
85b859c19Sderaadt
9cb39b413SmillertWEAK_ALIAS(index, strchr)
10f1bfdb2bSkettenis
115b859c19SderaadtENTRY(strchr)
125b859c19Sderaadt	movl	4(%esp),%eax
135b859c19Sderaadt	movb	8(%esp),%cl
145b859c19Sderaadt	.align 2,0x90
155b859c19SderaadtL1:
165b859c19Sderaadt	movb	(%eax),%dl
175b859c19Sderaadt	cmpb	%dl,%cl			/* found char??? */
185b859c19Sderaadt	je 	L2
195b859c19Sderaadt	incl	%eax
205b859c19Sderaadt	testb	%dl,%dl			/* null terminator??? */
215b859c19Sderaadt	jnz	L1
225b859c19Sderaadt	xorl	%eax,%eax
235b859c19SderaadtL2:
245b859c19Sderaadt	ret
259b9d2a55SguentherEND_STRONG(strchr)
26