2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A/ strrchr(const char *sp, int c) 2N/A/ if (*sp == (char)c) 2N/A pushl %edi / save register variable 2N/A movl 8(%esp), %eax / %eax = string address 2N/A movb 12(%esp), %cl / %cl = char sought 2N/A movl $0, %edi / %edi = NULL (current occurrence) 2N/A testl $3, %eax / if %eax not word aligned 2N/A movl (%eax), %edx / move 1 word from (%eax) to %edx 2N/A cmpb %cl, %dl / if the fist byte is not %cl 2N/A movl %eax, %edi / save this address to %edi 2N/A cmpb $0, %dl / if a null termination 2N/A cmpb %cl, %dh / if the second byte is not %cl 2N/A leal 1(%eax), %edi / save this address to %edi 2N/A cmpb $0, %dh / if a null termination 2N/A shrl $16, %edx / right shift 16-bit 2N/A cmpb %cl, %dl / if the third byte is not %cl 2N/A leal 2(%eax), %edi / save this address to %edi 2N/A cmpb $0, %dl / if a null termination 2N/A cmpb %cl, %dh / if the fourth byte is not %cl 2N/A leal 3(%eax), %edi / save this address to %edi 2N/A cmpb $0, %dh / if a null termination 2N/A addl $4, %eax / next word 2N/A movb (%eax), %dl / move 1 byte from (%eax) to %dl 2N/A cmpb %cl, %dl / if %dl is not %cl 2N/A movl %eax, %edi / save this address to %edi 2N/A cmpb $0, %dl / if a null termination 2N/A incl %eax / next byte 2N/A testl $3, %eax / if %eax not word aligned 2N/A jmp .L3 / goto .L3 (word aligned) 2N/A movl %edi, %eax / %edi points to the last occurrence or NULL 2N/A popl %edi / restore register variable