Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1627 serge 1
/*	memchr()					Author: Kees J. Bot */
2
/*								2 Jan 1994 */
3
 
4
/* void *memchr(const void *s, int c, size_t n) */
5
/*	Look for a character in a chunk of memory. */
6
/* */
7
#include "asm.h"
8
 
9
ENTRY(memchr)
10
	push	%ebp
11
	movl	%esp, %ebp
12
	push	%edi
13
	movl	8(%ebp), %edi	/* edi = string */
14
	movb	12(%ebp), %al	/* The character to look for */
15
	movl	16(%ebp), %ecx	/* Length */
16
	cmpb	$1, %cl	/* 'Z' bit must be clear if ecx = 0 */
17
	cld
18
 
19
	repne scasb
20
	jne	failure
21
	leal	-1(%edi), %eax	/* Found */
22
	pop	%edi
23
	pop	%ebp
24
	ret
25
failure:
26
	xorl	%eax, %eax
27
	pop	%edi
28
	pop	%ebp
29
	ret