// zasobnik - SKD
// by fallvonder 2007
// fallvonder.net


/*.DSEG
.ORG 0x100
pole: .BYTE 20

.CSEG
ldi r30, low(pole)
ldi r31, high(pole)
ldi r29, 20
ldi r28, 0x54

cycle: 
st Z+, r28
dec r29
brne cycle
lpm*/

//start: jmp loadstr
.org 0x00
.include "m169def.inc"
ldi r16, 0x00
out SPL, r16
ldi r16, 0x04
out SPH, r16

srcstr: .db "12345678weust99", 0


.dseg
deststr: .byte 256

.cseg

loadstr: ldi r30, low(srcstr<<1)
ldi r31, high(srcstr<<1)
ldi r28, low(deststr)
ldi r29, high(deststr)
cp_cycle: 
lpm
st Y+, r0
adiw r30, 1
tst r0
brne cp_cycle
call strlen

end:    rjmp    end

strlen:
	clr r17
	clz
	ldi r26, low(deststr)
	ldi r27, high(deststr)
	
	cyklus:
	ld r16, X+
	inc r17
	tst r16
	
	brne cyklus

ret
