11849Swollman/* 21849Swollman * Copyright (c) 1993 Winning Strategies, Inc. 31849Swollman * All rights reserved. 41849Swollman * 51849Swollman * Redistribution and use in source and binary forms, with or without 61849Swollman * modification, are permitted provided that the following conditions 71849Swollman * are met: 81849Swollman * 1. Redistributions of source code must retain the above copyright 91849Swollman * notice, this list of conditions and the following disclaimer. 101849Swollman * 2. Redistributions in binary form must reproduce the above copyright 111849Swollman * notice, this list of conditions and the following disclaimer in the 121849Swollman * documentation and/or other materials provided with the distribution. 131849Swollman * 3. All advertising materials mentioning features or use of this software 141849Swollman * must display the following acknowledgement: 151849Swollman * This product includes software developed by Winning Strategies, Inc. 161849Swollman * 4. The name of the author may not be used to endorse or promote products 1797748Sschweikh * derived from this software without specific prior written permission 181849Swollman * 191849Swollman * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 201849Swollman * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 211849Swollman * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 221849Swollman * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 231849Swollman * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 241849Swollman * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 251849Swollman * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 261849Swollman * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 271849Swollman * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 281849Swollman * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 291849Swollman */ 301849Swollman 3185437Speter#include <machine/asm.h> 3293000Sobrien__FBSDID("$FreeBSD$"); 331849Swollman 341849Swollman/* 351849Swollman * strrchr(s, c) 36249582Sgabor * return a pointer to the last occurrence of the character c in 371849Swollman * string s, or NULL if c does not occur in the string. 381849Swollman * 391849Swollman * %edx - pointer iterating through string 40249582Sgabor * %eax - pointer to last occurrence of 'c' 411849Swollman * %cl - character we're comparing against 421849Swollman * %bl - character at %edx 431849Swollman * 441849Swollman * Written by: 451849Swollman * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. 461849Swollman */ 471849Swollman 481849SwollmanENTRY(strrchr) 491849Swollman pushl %ebx 501849Swollman movl 8(%esp),%edx 511849Swollman movb 12(%esp),%cl 521849Swollman xorl %eax,%eax /* init pointer to null */ 531849Swollman .align 2,0x90 541849SwollmanL1: 551849Swollman movb (%edx),%bl 561849Swollman cmpb %bl,%cl 571849Swollman jne L2 581849Swollman movl %edx,%eax 591849SwollmanL2: 601849Swollman incl %edx 611849Swollman testb %bl,%bl /* null terminator??? */ 621849Swollman jne L1 631849Swollman popl %ebx 641849Swollman ret 65184548SpeterEND(strrchr) 66217106Skib 67229571SedWEAK_ALIAS(rindex, strrchr) 68229368Sed 69217106Skib .section .note.GNU-stack,"",%progbits 70