www.pudn.com > iccavr_lib.rar > cstrncpy.s, change:2003-11-08,size:556b


; rfm, based on strncpy 
.area text 
; 
; char *cstrncpy(char *dst, const char *src, size_t bytes) 
; 
_cstrncpy:: 
	ldd	R24,Y+0	; load length 
	ldd	R25,Y+1 
	cpi	R24,0 
	cpc	R25,R24 
	 breq	cstrncpyx	; length == 0 
	mov	R27,R17	; move pointers 
	mov	R26,R16 
	mov	R31,R19 
	mov	R30,R18 
cstrncpy1:			; copy 
	lpm 
	adiw	R30,1 
	st	X+,R0 
	sbiw	R24,1 
	 breq	cstrncpyx	; no more bytes ... 
	tst	R0 
	 brne	cstrncpy1	; src has more ... 
cstrncpy2:			; clear rest of dst 
	st	X+,R0 
	sbiw	R24,1 
	 brne	cstrncpy2 
cstrncpyx: 
	ret 
; 
;<eof; 2003-07-31 ja>