strchr.S revision 1.1.36.1 1 1.1.36.1 jym /* $NetBSD: strchr.S,v 1.1.36.1 2009/07/23 23:31:34 jym Exp $ */
2 1.1 christos
3 1.1.36.1 jym /*-
4 1.1.36.1 jym * Copyright (c) 1990 The Regents of the University of California.
5 1.1.36.1 jym * All rights reserved.
6 1.1.36.1 jym *
7 1.1.36.1 jym * This code is derived from software contributed to Berkeley by
8 1.1.36.1 jym * the Systems Programming Group of the University of Utah Computer
9 1.1.36.1 jym * Science Department.
10 1.1.36.1 jym *
11 1.1.36.1 jym * Redistribution and use in source and binary forms, with or without
12 1.1.36.1 jym * modification, are permitted provided that the following conditions
13 1.1.36.1 jym * are met:
14 1.1.36.1 jym * 1. Redistributions of source code must retain the above copyright
15 1.1.36.1 jym * notice, this list of conditions and the following disclaimer.
16 1.1.36.1 jym * 2. Redistributions in binary form must reproduce the above copyright
17 1.1.36.1 jym * notice, this list of conditions and the following disclaimer in the
18 1.1.36.1 jym * documentation and/or other materials provided with the distribution.
19 1.1.36.1 jym * 3. Neither the name of the University nor the names of its contributors
20 1.1.36.1 jym * may be used to endorse or promote products derived from this software
21 1.1.36.1 jym * without specific prior written permission.
22 1.1.36.1 jym *
23 1.1.36.1 jym * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 1.1.36.1 jym * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 1.1.36.1 jym * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 1.1.36.1 jym * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 1.1.36.1 jym * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 1.1.36.1 jym * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 1.1.36.1 jym * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.1.36.1 jym * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.1.36.1 jym * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.1.36.1 jym * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.1.36.1 jym * SUCH DAMAGE.
34 1.1.36.1 jym */
35 1.1.36.1 jym
36 1.1.36.1 jym #include <machine/asm.h>
37 1.1.36.1 jym
38 1.1.36.1 jym #if defined(LIBC_SCCS) && !defined(lint)
39 1.1.36.1 jym #if 0
40 1.1.36.1 jym RCSID("from: @(#)index.s 5.1 (Berkeley) 5/12/90")
41 1.1.36.1 jym #else
42 1.1.36.1 jym RCSID("$NetBSD: strchr.S,v 1.1.36.1 2009/07/23 23:31:34 jym Exp $")
43 1.1.36.1 jym #endif
44 1.1.36.1 jym #endif /* LIBC_SCCS and not lint */
45 1.1.36.1 jym
46 1.1.36.1 jym ENTRY(strchr)
47 1.1.36.1 jym movl %sp@(4),%a0 | string
48 1.1.36.1 jym movb %sp@(11),%d0 | char to look for
49 1.1.36.1 jym ixloop:
50 1.1.36.1 jym cmpb %a0@,%d0 | found our char?
51 1.1.36.1 jym jeq ixfound | yes, break out
52 1.1.36.1 jym tstb %a0@+ | null?
53 1.1.36.1 jym jne ixloop | no, keep going
54 1.1.36.1 jym moveq #0,%d0 | not found, return null
55 1.1.36.1 jym #ifdef __SVR4_ABI__
56 1.1.36.1 jym moveal %d0,%a0
57 1.1.36.1 jym #endif
58 1.1.36.1 jym rts
59 1.1.36.1 jym ixfound:
60 1.1.36.1 jym movl %a0,%d0 | found, return pointer
61 1.1.36.1 jym rts
62 1.1.36.1 jym
63 1.1.36.1 jym STRONG_ALIAS(index,strchr)
64