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