1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
22 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
23 * Use is subject to license terms.
24 */
25
26	.file	"strchr.s"
27
28#include "SYS.h"
29
30	ENTRY(strchr)		/* (char *, char) */
31.loop:
32	movb	(%rdi),%dl	/ %dl = byte of string
33	cmpb	%sil,%dl	/ find it?
34	je	.found		/ yes
35	testb	%dl,%dl		/ is it null?
36	je	.notfound
37
38	movb	1(%rdi),%dl	/ %dl = byte of string
39	cmpb	%sil,%dl	/ find it?
40	je	.found1		/ yes
41	testb	%dl,%dl		/ is it null?
42	je	.notfound
43
44	movb	2(%rdi),%dl	/ %dl = byte of string
45	cmpb	%sil,%dl	/ find it?
46	je	.found2		/ yes
47	testb	%dl,%dl		/ is it null?
48	je	.notfound
49
50	movb	3(%rdi),%dl	/ %dl = byte of string
51	cmpb	%sil,%dl	/ find it?
52	je	.found3		/ yes
53	addq	$4,%rdi
54	testb	%dl,%dl		/ is it null?
55	jne	.loop
56
57.notfound:
58	xorl	%eax,%eax	/ %rax = NULL
59	ret
60
61.found3:
62	incq	%rdi
63.found2:
64	incq	%rdi
65.found1:
66	incq	%rdi
67.found:
68	movq	%rdi,%rax
69	ret
70	SET_SIZE(strchr)
71