source: trunk/minix/lib/i386/string/memchr.s@ 11

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

Minix 3.1.2a

File size: 559 bytes
Line 
1! memchr() Author: Kees J. Bot
2! 2 Jan 1994
3.sect .text; .sect .rom; .sect .data; .sect .bss
4
5! void *memchr(const void *s, int c, size_t n)
6! Look for a character in a chunk of memory.
7!
8.sect .text
9.define _memchr
10 .align 16
11_memchr:
12 push ebp
13 mov ebp, esp
14 push edi
15 mov edi, 8(ebp) ! edi = string
16 movb al, 12(ebp) ! The character to look for
17 mov ecx, 16(ebp) ! Length
18 cmpb cl, 1 ! 'Z' bit must be clear if ecx = 0
19 cld
20 repne
21 scasb
22 jne failure
23 lea eax, -1(edi) ! Found
24 pop edi
25 pop ebp
26 ret
27failure:xor eax, eax
28 pop edi
29 pop ebp
30 ret
Note: See TracBrowser for help on using the repository browser.