import less(1)
[unleashed/tickless.git] / usr / src / lib / libc / amd64 / gen / strchr.s
blob57008111b61cc84cd6f31d5b2fdccc5bd67503c8
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
22 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 .file "strchr.s"
28 #include "SYS.h"
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
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
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
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
57 .notfound:
58 xorl %eax,%eax / %rax = NULL
59 ret
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)