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
/*	_strncpy()					Author: Kees J. Bot */
2
/*								1 Jan 1994 */
1408 serge 3
 
1627 serge 4
/* char *_strncpy(char *s1, const char *s2, size_t ecx) */
5
/*	Copy string s2 to s1. */
6
/* */
7
#include "asm.h"
1408 serge 8
 
1627 serge 9
ENTRY(_strncpy)
10
	movl	12(%ebp), %edi	/* edi = string s2 */
11
	xorb	%al, %al	/* Look for a zero byte */
12
	movl	%ecx, %edx	/* Save maximum count */
13
	cld
1408 serge 14
 
1627 serge 15
	repne scasb	/* Look for end of s2 */
16
	subl	%ecx, %edx	/* Number of bytes in s2 including null */
17
	xchgl	%edx, %ecx
18
	movl	12(%ebp), %esi	/* esi = string s2 */
19
	movl	8(%ebp), %edi	/* edi = string s1 */
1408 serge 20
 
1627 serge 21
	rep movsb	/* Copy bytes */
1408 serge 22
	ret