source: trunk/minix/lib/i386/string/strrchr.s@ 10

Last change on this file since 10 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 736 bytes
Line 
1! strrchr() Author: Kees J. Bot
2! 2 Jan 1994
3.sect .text; .sect .rom; .sect .data; .sect .bss
4
5! char *strrchr(const char *s, int c)
6! Look for the last occurrence a character in a string.
7!
8.sect .text
9.define _strrchr
10 .align 16
11_strrchr:
12 push ebp
13 mov ebp, esp
14 push edi
15 mov edi, 8(ebp) ! edi = string
16 mov ecx, -1
17 xorb al, al
18 cld
19 repne
20 scasb ! Look for the end of the string
21 not ecx ! -1 - ecx = Length of the string + null
22 dec edi ! Put edi back on the zero byte
23 movb al, 12(ebp) ! The character to look for
24 std ! Downwards search
25 repne
26 scasb
27 cld ! Direction bit back to default
28 jne failure
29 lea eax, 1(edi) ! Found it
30 pop edi
31 pop ebp
32 ret
33failure:xor eax, eax ! Not there
34 pop edi
35 pop ebp
36 ret
Note: See TracBrowser for help on using the repository browser.