Home | History | Annotate | Line # | Download | only in string
strrchr.S revision 1.2.6.1
      1  1.2.6.1      yamt /*	$NetBSD: strrchr.S,v 1.2.6.1 2014/05/22 11:26:29 yamt 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: @(#)rindex.s	5.1 (Berkeley) 5/12/90")
     41      1.2       dsl #else
     42  1.2.6.1      yamt 	RCSID("$NetBSD: strrchr.S,v 1.2.6.1 2014/05/22 11:26:29 yamt 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(strrchr)
     47  1.2.6.1      yamt 	movl	4(%sp),%a1		| string
     48  1.2.6.1      yamt 	movb	11(%sp),%d0		| char to look for
     49      1.2       dsl 	subl	%a0,%a0			| clear rindex pointer
     50      1.2       dsl rixloop:
     51  1.2.6.1      yamt 	cmpb	(%a1),%d0		| found our char?
     52      1.2       dsl 	jne	rixnope			| no, check for null
     53      1.2       dsl 	movl	%a1,%a0			| yes, remember location
     54      1.2       dsl rixnope:
     55  1.2.6.1      yamt 	tstb	(%a1)+			| null?
     56      1.2       dsl 	jne	rixloop			| no, keep going
     57      1.2       dsl 	movl	%a0,%d0			| return value
     58      1.2       dsl 	rts
     59  1.2.6.1      yamt END(strrchr)
     60      1.2       dsl 
     61      1.2       dsl STRONG_ALIAS(rindex,strrchr)
     62