1/* $OpenBSD: rindex.S,v 1.3 2005/08/07 11:30:38 espie Exp $ */ 2/* 3 * Written by J.T. Conklin <jtc@netbsd.org>. 4 * Public domain. 5 */ 6 7#include <machine/asm.h> 8 9 .section .comment 10 .asciz "$MirOS: src/kern/c/i386/strrchr.S,v 1.1 2011/01/03 19:02:50 tg Exp $" 11 12 .text 13 14NENTRY(strrchr) 15ENTRY(rindex) 16 pushl %ebx 17 movl 8(%esp),%edx 18 movb 12(%esp),%cl 19 xorl %eax,%eax /* init pointer to null */ 20 .align 2,0x90 21L1: 22 movb (%edx),%bl 23 cmpb %bl,%cl 24 jne L2 25 movl %edx,%eax 26L2: 27 incl %edx 28 testb %bl,%bl /* null terminator??? */ 29 jnz L1 30 popl %ebx 31 ret 32