Rev 1408 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1408 | Rev 1627 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | # _strncpy() Author: Kees J. Bot |
1 | /* _strncpy() Author: Kees J. Bot */ |
2 | # 1 Jan 1994 |
2 | /* 1 Jan 1994 */ |
Line 3... | Line 3... | ||
3 | 3 | ||
4 | # char *_strncpy(char *s1, const char *s2, size_t ecx) |
4 | /* char *_strncpy(char *s1, const char *s2, size_t ecx) */ |
5 | # Copy string s2 to s1. |
5 | /* Copy string s2 to s1. */ |
- | 6 | /* */ |
|
Line 6... | Line 7... | ||
6 | # |
7 | #include "asm.h" |
- | 8 | ||
- | 9 | ENTRY(_strncpy) |
|
- | 10 | movl 12(%ebp), %edi /* edi = string s2 */ |
|
- | 11 | xorb %al, %al /* Look for a zero byte */ |
|
Line -... | Line 12... | ||
- | 12 | movl %ecx, %edx /* Save maximum count */ |
|
- | 13 | cld |
|
7 | 14 | ||
8 | .intel_syntax |
15 | repne scasb /* Look for end of s2 */ |
9 | 16 | subl %ecx, %edx /* Number of bytes in s2 including null */ |
|
Line 10... | Line -... | ||
10 | .text |
- | |
11 | .globl __strncpy |
- | |
12 | .align 16 |
- | |
13 | - | ||
14 | __strncpy: |
- | |
15 | mov edi, [ebp+12] # edi = string s2 |
- | |
16 | xorb al, al # Look for a zero byte |
- | |
17 | mov edx, ecx # Save maximum count |
- | |
18 | cld |
- | |
19 | repne |
- | |
20 | scasb # Look for end of s2 |
- | |
21 | sub edx, ecx # Number of bytes in s2 including null |
- | |
22 | xchg ecx, edx |
17 | xchgl %edx, %ecx |
23 | mov esi, [ebp+12] # esi = string s2 |
18 | movl 12(%ebp), %esi /* esi = string s2 */ |