;/* Title	: String (ASCIIZ) routines for AVR */
;/* Author	: Jan Skalicky, 2005 */
;/* Content : strcpy	| copy string from Flash to RAM	| X,X+1...<-Z,Z+1...	*/
;/*			  strlen	| count string length | r2 = strlen(X)					*/

strcpy:
	push	r0
	push	XL
	push	XH
	push	ZL
	push	ZH
strcpy_loop:	
	lpm		r0, Z+
	st		X+, r0
	tst		r0
	brne	strcpy_loop

	pop		ZH
	pop		ZL
	pop		XH
	pop		XL
	pop		r0
	ret

strlen:
	push	r0
	push	XL
	push	XH

	clr		r2
strlen_loop:
	ld		r0, X+
	tst		r0
	breq	strlen_exit
	inc		r2
	rjmp	strlen_loop
strlen_exit:
	pop		XH
	pop		XL
	pop		r0
	ret

