source: trunk/minix/lib/i86/string/memchr.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: 529 bytes
Line 
1! memchr() Author: Kees J. Bot
2! 27 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_memchr:
11 push bp
12 mov bp, sp
13 push di
14 mov di, 4(bp) ! di = string
15 movb al, 6(bp) ! The character to look for
16 mov cx, 8(bp) ! Length
17 cmpb cl, #1 ! 'Z' bit must be clear if cx = 0
18 cld
19 repne scasb
20 jne failure
21 lea ax, -1(di) ! Found
22 pop di
23 pop bp
24 ret
25failure:xor ax, ax
26 pop di
27 pop bp
28 ret
Note: See TracBrowser for help on using the repository browser.