;+----------------------------------------------------------------------
;| Titel		: myAVR Beispiel Lauflicht für den ATmega8
;+----------------------------------------------------------------------
;| Funktion		: Ein Register wird inkrementiert und verzögert an
;|		: PORTD ausgegeben.
;| Schaltung	: PORTD2=Summer, PORTD3=LED1, PORTD4=LED2, PORTD5=LED3
;+----------------------------------------------------------------------
;| Prozessor	: ATmega8
;| Takt		: 3,6864 MHz
;| Sprache		: Assembler
;| Datum		: 02.04.2004
;| Version		: 1.4
;| Autor		: Dipl. Ing. Päd. Alexander Huwaldt
;+----------------------------------------------------------------------
.include	"AVR.H"
;------------------------------------------------------------------------
;Reset and Interrupt vector             ;VNr.  Beschreibung
	rjmp	main	;1     POWER ON RESET
	reti		;2     Int0-Interrupt
	reti		;3     Int1-Interrupt
	reti		;4     TC2 Compare Match
	reti		;5     TC2 Overflow
	reti		;6     TC1 Capture
	reti		;7     TC1 Compare Match A
	reti		;8     TC1 Compare Match B
	reti		;9     TC1 Overflow
	reti		;10    TC0 Overflow
	reti		;11    SPI, STC Serial Transfer Complete
	reti		;12    UART Rx Complete
	reti		;13    UART Data Register Empty
	reti		;14    UART Tx Complete
	reti		;15    ADC Conversion Complete
	reti		;16    EEPROM Ready
	reti		;17    Analog Comparator
	reti		;18    TWI (I²C) Serial Interface
	reti		;19    Store Program Memory Ready
;------------------------------------------------------------------------
;Start, Power ON, Reset
main:	ldi	r16,lo8(RAMEND)
	out	SPL,r16
	ldi	r16,hi8(RAMEND)
	out	SPH,r16	;Init Stackpointer
	ldi	r16,0b11111111	;PORTD auf Ausgang
	out	DDRD,r16
	ldi	r16,0b00000000	;alle Bits auf Low
	out	PORTD,r16
	ldi	r17,0b00000000
	ldi	r18,0b00000001	;1 Lauflicht-Bit
;------------------------------------------------------------------------
mainloop:	wdr
	inc	r16	;wait
	brne	skip
	inc	r17	;wait
	brne	skip
	rcall	run	;Lauflicht
skip:	rjmp	mainloop
;------------------------------------------------------------------------
run:	rol	r18	;Bit-Rotation
	out	PORTD,r18	;Ausgabe
	ret		;Rücksprung
;------------------------------------------------------------------------

