home *** CD-ROM | disk | FTP | other *** search
- / strrchr.s (emx+gcc) -- Copyright (c) 1990-1993 by Eberhard Mattes
-
- .globl _strrchr
-
- / char *strrchr (const char *string, int c)
- / {
- / int i;
- /
- / i = 0;
- / while (string[i] != 0) ++i;
- / while (i >= 0)
- / if (string[i] == (char)c)
- / return ((char *)(string+i));
- / else
- / --i;
- / return (NULL);
- / }
-
- .text
-
- .align 2, 0x90
-
- _strrchr:
- pushl %edi
- movl 2*4(%esp), %edi / string
- movl $-1, %ecx
- xorb %al, %al
- repne
- scasb
- notl %ecx / ecx = strlen (string) + 1
- decl %edi / edi = string + strlen (string)
- movb 3*4(%esp), %al / c
- std
- repne
- scasb
- cld
- jne 1f
- lea 1(%edi), %eax
- popl %edi
- ret
-
- .align 2, 0x90
- 1: xorl %eax, %eax
- popl %edi
- ret
-