source: trunk/minix/lib/i86/string/strrchr.s@ 9

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

Minix 3.1.2a

File size: 706 bytes
Line 
1! strrchr() Author: Kees J. Bot
2! 27 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_strrchr:
11 push bp
12 mov bp, sp
13 push di
14 mov di, 4(bp) ! di = string
15 mov cx, #-1
16 xorb al, al
17 cld
18 repne scasb ! Look for the end of the string
19 not cx ! -1 - cx = Length of the string + null
20 dec di ! Put di back on the zero byte
21 movb al, 6(bp) ! The character to look for
22 std ! Downwards search
23 repne scasb
24 cld ! Direction bit back to default
25 jne failure
26 lea ax, 1(di) ! Found it
27 pop di
28 pop bp
29 ret
30failure:xor ax, ax ! Not there
31 pop di
32 pop bp
33 ret
Note: See TracBrowser for help on using the repository browser.