; Program: LED posun1
; LEDy su na porte C

.nolist
.include "m32def.inc"
.list

.cseg
.equ F_CPU = 16000000

.def REG = R16
.equ DDR = DDRC
.equ PORT = PORTC

init:	ldi REG, high(ramend)
		out SPH, REG
		ldi REG, low(ramend)
		out SPL, REG

		ser REG
		out DDR, REG	; vystupny cely port

main:	ldi REG, 0x01	; 0b00000001, 1<<0, 1<<PC0, 1<<PORTC0
		out PORT, REG
		rcall cakaj

		ldi REG, 0x02	; 0b00000010, 1<<1, 1<<PC1, 1<<PORTC1
		out PORT, REG
		rcall cakaj

		ldi REG, 0x04	; 0b00000100, 1<<2, 1<<PC2, 1<<PORTC2
		out PORT, REG
		rcall cakaj

		ldi REG, 0x08	; 0b00001000, 1<<3, 1<<PC3, 1<<PORTC3
		out PORT, REG
		rcall cakaj

		; a tak dalej (ja niin edelleen)

		rjmp main


; subrutina cakaj
cakaj:	ldi R17, 4		; i (vonkajsi cyklus)
		clr R18			; j
		clr R19			; k
loop:	nop
		dec R19
;		brne loop		; pri ladeni zakomentovat
		dec R18
;		brne loop		; pri ladeni zakomentovat
		dec R17
		brne loop		; skace ak nie je nula, flag Z v SREG vynulovany
		ret


; BRNE (BRanch is Not Equal)



