Subversion Repositories Kolibri OS

Rev

Rev 1408 | Details | Compare with Previous | Last modification | View Log | RSS feed

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