	;Expt3.asm
        ;Project: Running LEDs
	;List P = 16F84
	;#include <p16F84.inc>
	;__CONFIG 1Bh    ;_CP_OFF & _PWRTE_ON & _WDT_OFF & _RC_OSC


	ORG 0		;This is the start of memory for the program.
SetUp	BSF 03,5	;Go to Bank 1
	CLRF 06		;Make all port B output
	MOVLW 01	;Load W with 0000 0001
	MOVWF 05	;Make RA0 input
	BCF 03,5	;Go to Bank 0 - the program memory area.
	BCF 03,0	;Clear the carry flag
	GOTO Main
		

Delay	MOVLW 64h	;Load W with 100. Create 100mS delay
	MOVLW 1B
Delay1	NOP
	DECFSZ 1A,1
	GOTO Delay1
	DECFSZ 1B,1
	GOTO Delay1
Delay2	BTFSC 05,0	;Look at input
	GOTO Delay2	;Button pressed. Stop action
	RETURN		;Return

Main	MOVLW 01	;Put 0000 0001 into W
	MOVWF 06	;Illuminate the lowest LED
Main2	RLF 06,1	;Shift to the left so that end LED shows equal time
Main3	RLF 06,1	;Shift LED to the left.
	BTFSC 03,0	;Has LED reached end of display?
	GOTO Main4	;Yes
	CALL Delay	;No. Illuminate LED
	GOTO Main3	;Loop shift-left instructions.
Main4	RRF 06,1	;Shift to the right so that end LED shows equal time
Main5	RRF 06,1	;Shift LED to the right.
	BTFSC 03,0	;Has LED reached end of display?
	GOTO Main2	;Yes. 
	CALL Delay	;No. Illuminate LED
	GOTO Main5	;Loop shift-right instructions.

	END		;Tells assembler end of program