strrchr.S revision 229571
113547Sjulian/* 213547Sjulian * Copyright (c) 1993 Winning Strategies, Inc. 313547Sjulian * All rights reserved. 413547Sjulian * 513547Sjulian * Redistribution and use in source and binary forms, with or without 613547Sjulian * modification, are permitted provided that the following conditions 713547Sjulian * are met: 813547Sjulian * 1. Redistributions of source code must retain the above copyright 913547Sjulian * notice, this list of conditions and the following disclaimer. 1013547Sjulian * 2. Redistributions in binary form must reproduce the above copyright 1113547Sjulian * notice, this list of conditions and the following disclaimer in the 1213547Sjulian * documentation and/or other materials provided with the distribution. 1313547Sjulian * 3. All advertising materials mentioning features or use of this software 1413547Sjulian * must display the following acknowledgement: 1513547Sjulian * This product includes software developed by Winning Strategies, Inc. 1613547Sjulian * 4. The name of the author may not be used to endorse or promote products 1713547Sjulian * derived from this software without specific prior written permission 1813547Sjulian * 1913547Sjulian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 2013547Sjulian * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2113547Sjulian * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2213547Sjulian * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2313547Sjulian * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2413547Sjulian * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2513547Sjulian * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2613547Sjulian * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2713547Sjulian * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2813547Sjulian * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2913547Sjulian */ 3013547Sjulian 3113547Sjulian#include <machine/asm.h> 3250473Speter__FBSDID("$FreeBSD: head/lib/libc/i386/string/strrchr.S 229571 2012-01-05 10:32:53Z ed $"); 3313547Sjulian 3413547Sjulian/* 3513547Sjulian * strrchr(s, c) 3613547Sjulian * return a pointer to the last occurance of the character c in 3713547Sjulian * string s, or NULL if c does not occur in the string. 3813547Sjulian * 3913547Sjulian * %edx - pointer iterating through string 4013547Sjulian * %eax - pointer to last occurance of 'c' 4113547Sjulian * %cl - character we're comparing against 4213547Sjulian * %bl - character at %edx 4313547Sjulian * 4413547Sjulian * Written by: 4513547Sjulian * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. 46 */ 47 48ENTRY(strrchr) 49 pushl %ebx 50 movl 8(%esp),%edx 51 movb 12(%esp),%cl 52 xorl %eax,%eax /* init pointer to null */ 53 .align 2,0x90 54L1: 55 movb (%edx),%bl 56 cmpb %bl,%cl 57 jne L2 58 movl %edx,%eax 59L2: 60 incl %edx 61 testb %bl,%bl /* null terminator??? */ 62 jne L1 63 popl %ebx 64 ret 65END(strrchr) 66 67WEAK_ALIAS(rindex, strrchr) 68 69 .section .note.GNU-stack,"",%progbits 70