strrchr.S revision 93000
1219019Sgabor/* 2219019Sgabor * Copyright (c) 1993 Winning Strategies, Inc. 3219019Sgabor * All rights reserved. 4219019Sgabor * 5219019Sgabor * Redistribution and use in source and binary forms, with or without 6219019Sgabor * modification, are permitted provided that the following conditions 7219019Sgabor * are met: 8219019Sgabor * 1. Redistributions of source code must retain the above copyright 9219019Sgabor * notice, this list of conditions and the following disclaimer. 10219019Sgabor * 2. Redistributions in binary form must reproduce the above copyright 11219019Sgabor * notice, this list of conditions and the following disclaimer in the 12219019Sgabor * documentation and/or other materials provided with the distribution. 13219019Sgabor * 3. All advertising materials mentioning features or use of this software 14219019Sgabor * must display the following acknowledgement: 15219019Sgabor * This product includes software developed by Winning Strategies, Inc. 16219019Sgabor * 4. The name of the author may not be used to endorse or promote products 17219019Sgabor * derived from this software withough specific prior written permission 18219019Sgabor * 19219019Sgabor * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20219019Sgabor * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21219019Sgabor * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22219019Sgabor * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23219019Sgabor * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24219019Sgabor * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25219019Sgabor * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26219019Sgabor * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27219019Sgabor * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28219019Sgabor * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29219019Sgabor */ 30219019Sgabor 31219019Sgabor#include <machine/asm.h> 32219019Sgabor__FBSDID("$FreeBSD: head/lib/libc/i386/string/strrchr.S 93000 2002-03-23 02:44:19Z obrien $"); 33219019Sgabor 34219019Sgabor/* 35219019Sgabor * strrchr(s, c) 36219019Sgabor * return a pointer to the last occurance of the character c in 37219019Sgabor * string s, or NULL if c does not occur in the string. 38219019Sgabor * 39219019Sgabor * %edx - pointer iterating through string 40219019Sgabor * %eax - pointer to last occurance of 'c' 41219019Sgabor * %cl - character we're comparing against 42219019Sgabor * %bl - character at %edx 43219019Sgabor * 44219019Sgabor * Written by: 45219019Sgabor * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. 46219019Sgabor */ 47219019Sgabor 48219019SgaborENTRY(strrchr) 49219019Sgabor pushl %ebx 50219019Sgabor movl 8(%esp),%edx 51219019Sgabor movb 12(%esp),%cl 52219019Sgabor xorl %eax,%eax /* init pointer to null */ 53219019Sgabor .align 2,0x90 54219019SgaborL1: 55219019Sgabor movb (%edx),%bl 56219019Sgabor cmpb %bl,%cl 57219019Sgabor jne L2 58219019Sgabor movl %edx,%eax 59219019SgaborL2: 60219019Sgabor incl %edx 61219019Sgabor testb %bl,%bl /* null terminator??? */ 62219019Sgabor jne L1 63219019Sgabor popl %ebx 64219019Sgabor ret 65219019Sgabor