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
|
---|
27 | failure:xor eax, eax
|
---|
28 | pop edi
|
---|
29 | pop ebp
|
---|
30 | ret
|
---|
Note:
See
TracBrowser
for help on using the repository browser.