	.386
	.model use32 small
	public _strncpy
	.code
_strncpy:
	push	ebp
	mov	ebp,esp
	push	esi
	push	edi
	mov	edi,[ebp+12]
	mov	ecx,-1
	sub	al,al
	cld
	repne	scasb
	not	ecx
	dec	ecx
	mov	edx,[ebp+16]
	sub	edx,ecx
	jge	short useecx
	mov	ecx,[ebp+16]
useecx:
	mov	esi,[ebp+12]
	mov	edi,[ebp+8]
	rep	movsb

	or	edx,edx
	jle	short nopad
	mov	ecx,edx
	sub	al,al
	rep	stosb

nopad:
	mov	eax,[ebp+8]
	pop	edi
	pop	esi
	pop	ebp
	ret
	end