source: trunk/minix/lib/i386/string/_strnlen.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: 584 bytes
Line 
1! _strnlen() Author: Kees J. Bot
2! 1 Jan 1994
3.sect .text; .sect .rom; .sect .data; .sect .bss
4
5! size_t _strnlen(const char *s, size_t ecx)
6! Return the length of a string.
7!
8.sect .text
9.define __strnlen
10 .align 16
11__strnlen:
12 push ebp
13 mov ebp, esp
14 push edi
15 mov edi, 8(ebp) ! edi = string
16 xorb al, al ! Look for a zero byte
17 mov edx, ecx ! Save maximum count
18 cmpb cl, 1 ! 'Z' bit must be clear if ecx = 0
19 cld
20 repne
21 scasb ! Look for zero
22 jne no0
23 inc ecx ! Don't count zero byte
24no0: mov eax, edx
25 sub eax, ecx ! Compute bytes scanned
26 pop edi
27 pop ebp
28 ret
Note: See TracBrowser for help on using the repository browser.