
;------------------------------------------
;Project Name:  Led Chase.asm
;Description:	LED's bounce back and forth 
;Author:		Max Koessick
;Date;			July 7, 2003
;Revision:		One
;------------------------------------------

.include "m323def.inc" 		; Default Include file for ATMega128


;Interrupt Service Vector Addresses

.org $0000
	rjmp RESET				; Reset Vector

;-------------------------------------------
;Register Definitions
;-------------------------------------------

.def mpr   		=r16		; Temporary Register
.def delay 		=r17		; Delay Variable Register 1
.def delay2		=r18		; Delay Variable Register 2
.def eight		=r19		; 8 Counter for 8 discrete LEDs


;Initialization

RESET:

		ser		mpr		
		out		DDRC,mpr	; Set PORTC to output


		ldi 	mpr,$7f	; Turn on left most LED (Active Low)
		out		PORTC,mpr	; Output to LEDs on ShopBot
		

LOOP:

		ldi		Eight,$08

RightLoop:
		
		ror		mpr		; Rotate LEDs one right
		out		PORTC,mpr	; Output to LEDs on ShopBot
	
;Wait to make LEDs visible 

DLY:
		dec		delay
		brne	dly
		dec		delay2
		brne	dly


		dec		eight		; Shift the light eight times
		brne	rightloop

		ldi		eight,$08

LeftLoop:
		
		rol		mpr
		out		PORTC,mpr	; Output to LEDs on ShopBot


dly2:

		dec		delay
		brne	dly2
		dec		delay2
		brne	dly2



		dec 	eight
		brne 	leftloop

		rjmp	loop		; Repeat forver
