Subversion Repositories Kolibri OS

Rev

Rev 1408 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1408 Rev 1627
Line 1... Line 1...
1
# _strnlen() Author: Kees J. Bot  1 Jan 1994
1
/*	_strnlen()					Author: Kees J. Bot */
-
 
2
/*								1 Jan 1994 */
Line 2... Line 3...
2
 
3
 
3
# size_t _strnlen(const char *s, size_t ecx)
4
/* size_t _strnlen(const char *s, size_t ecx) */
-
 
5
/*	Return the length of a string. */
-
 
6
/* */
Line 4... Line -...
4
# Return the length of a string.
-
 
5
 
-
 
6
.intel_syntax
7
#include "asm.h"
7
 
-
 
8
.globl __strnlen
-
 
9
 
-
 
10
.text
8
 
11
           .align  16
-
 
12
__strnlen:
9
ENTRY(_strnlen)
13
           push    ebp
10
	push	%ebp
14
           mov     ebp, esp
11
	movl	%esp, %ebp
15
           push    edi
12
	push	%edi
16
           mov     edi, [ebp+8]    # edi = string
13
	movl	8(%ebp), %edi	/* edi = string */
17
           xorb    al, al          # Look for a zero byte
14
	xorb	%al, %al	/* Look for a zero byte */
18
           mov     edx, ecx        # Save maximum count
15
	movl	%ecx, %edx	/* Save maximum count */
19
           cmpb    cl, 1           # 'Z' bit must be clear if ecx = 0
-
 
-
 
16
	cmpb	$1, %cl	/* 'Z' bit must be clear if ecx = 0 */
20
           cld
17
	cld
21
           repne
18
 
22
           scasb                   # Look for zero
19
	repne scasb	/* Look for zero */
23
           jne     no0
20
	jne	no0
24
           inc     ecx             # Don't count zero byte
21
	incl	%ecx	/* Don't count zero byte */
25
no0:
22
no0:
26
           mov     eax, edx
23
	movl	%edx, %eax
27
           sub     eax, ecx        # Compute bytes scanned
24
	subl	%ecx, %eax	/* Compute bytes scanned */
28
           pop     edi
25
	pop	%edi