Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

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