strrchr.S revision 93000
10Sduke/* 22362Sohair * Copyright (c) 1993 Winning Strategies, Inc. 30Sduke * All rights reserved. 40Sduke * 50Sduke * Redistribution and use in source and binary forms, with or without 60Sduke * modification, are permitted provided that the following conditions 70Sduke * are met: 80Sduke * 1. Redistributions of source code must retain the above copyright 90Sduke * notice, this list of conditions and the following disclaimer. 100Sduke * 2. Redistributions in binary form must reproduce the above copyright 110Sduke * notice, this list of conditions and the following disclaimer in the 120Sduke * documentation and/or other materials provided with the distribution. 130Sduke * 3. All advertising materials mentioning features or use of this software 140Sduke * must display the following acknowledgement: 150Sduke * This product includes software developed by Winning Strategies, Inc. 160Sduke * 4. The name of the author may not be used to endorse or promote products 170Sduke * derived from this software withough specific prior written permission 180Sduke * 192362Sohair * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 202362Sohair * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 212362Sohair * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 220Sduke * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 230Sduke * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 240Sduke * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 250Sduke * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 260Sduke * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 270Sduke * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 280Sduke * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 290Sduke */ 300Sduke 310Sduke#include <machine/asm.h> 320Sduke__FBSDID("$FreeBSD: head/lib/libc/i386/string/strrchr.S 93000 2002-03-23 02:44:19Z obrien $"); 330Sduke 340Sduke/* 350Sduke * strrchr(s, c) 360Sduke * return a pointer to the last occurance of the character c in 370Sduke * string s, or NULL if c does not occur in the string. 380Sduke * 390Sduke * %edx - pointer iterating through string 400Sduke * %eax - pointer to last occurance of 'c' 410Sduke * %cl - character we're comparing against 420Sduke * %bl - character at %edx 430Sduke * 440Sduke * Written by: 450Sduke * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. 460Sduke */ 470Sduke 480SdukeENTRY(strrchr) 490Sduke pushl %ebx 500Sduke movl 8(%esp),%edx 510Sduke movb 12(%esp),%cl 520Sduke xorl %eax,%eax /* init pointer to null */ 530Sduke .align 2,0x90 540SdukeL1: 550Sduke movb (%edx),%bl 560Sduke cmpb %bl,%cl 570Sduke jne L2 580Sduke movl %edx,%eax 590SdukeL2: 600Sduke incl %edx 610Sduke testb %bl,%bl /* null terminator??? */ 620Sduke jne L1 630Sduke popl %ebx 640Sduke ret 650Sduke