;/* Title	: String Concat */
;/* Author	: Jan Skalicky, 2005 */


	.org 0
	.cseg
	jmp		start

str_1:	.db "bla", 0
str_2:	.db "glo", 0

	.dseg
	.org 0x100

str_1c:	.byte 4
str_2c: .byte 4
str:	.byte 8

	.cseg

start:
	ldi		r30, low(str_1<<1)
	ldi		r31, high(str_1<<1)
	ldi		r28, low(str_1c)
	ldi		r29, high(str_1c)

cycle_1:
	lpm		r0, Z+
	st		Y+, r0
	tst		r0
	brne	cycle_1

start2:
	ldi		r30, low(str_2<<1)
	ldi		r31, high(str_2<<1)
	ldi		r28, low(str_2c)
	ldi		r29, high(str_2c)

cycle_2:
	lpm		r0, Z+
	st		Y+, r0
	tst		r0
	brne	cycle_2

cat:
	ldi		r28, low(str)
	ldi		r29, high(str)

	ldi		r26, low(str_1c)
	ldi		r27, high(str_1c)

cycle_3:
	ld		r0, X+
	tst		r0
	breq	second
	st		Y+, r0
	rjmp	cycle_3

second:
	ldi		r26, low(str_2c)
	ldi		r27, high(str_2c)
cycle_4:
	ld		r0, X+
	tst		r0
	breq	end
	st		Y+, r0
	rjmp	cycle_4

end:
	ldi		r20, 0
	st		Y, r20

looop:
	rjmp	PC