source: trunk/minix/lib/i386/string/_strncat.s@ 10

Last change on this file since 10 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 874 bytes
Line 
1! _strncat() Author: Kees J. Bot
2! 1 Jan 1994
3.sect .text; .sect .rom; .sect .data; .sect .bss
4
5! char *_strncat(char *s1, const char *s2, size_t edx)
6! Append string s2 to s1.
7!
8.sect .text
9.define __strncat
10 .align 16
11__strncat:
12 push ebp
13 mov ebp, esp
14 push esi
15 push edi
16 mov edi, 8(ebp) ! String s1
17 mov ecx, -1
18 xorb al, al ! Null byte
19 cld
20 repne
21 scasb ! Look for the zero byte in s1
22 dec edi ! Back one up (and clear 'Z' flag)
23 push edi ! Save end of s1
24 mov edi, 12(ebp) ! edi = string s2
25 mov ecx, edx ! Maximum count
26 repne
27 scasb ! Look for the end of s2
28 jne no0
29 inc ecx ! Exclude null byte
30no0: sub edx, ecx ! Number of bytes in s2
31 mov ecx, edx
32 mov esi, 12(ebp) ! esi = string s2
33 pop edi ! edi = end of string s1
34 rep
35 movsb ! Copy bytes
36 stosb ! Add a terminating null
37 mov eax, 8(ebp) ! Return s1
38 pop edi
39 pop esi
40 pop ebp
41 ret
Note: See TracBrowser for help on using the repository browser.