	;Expt8.asm
        ;Project: 0-256 parts of an input
	;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 1F
	MOVWF 05	;Make port A input
	BCF 03,5	;Go to Bank 0 - the program memory area.	
	CLRF 06		;Clear display
	GOTO Main

Delay	MOVLW 80h	;Create 100mS delay
	MOVWF 1B		
DelayA	DECFSZ 1A,1
	GOTO DelayA
	DECFSZ 1B,1
	GOTO DelayA
	RETURN

Delay2	NOP		;Create approx 250mS delay
	DECFSZ 1A,1
	GOTO Delay2
	DECFSZ 1B,1
	GOTO Delay2
	RETURN


Look	CLRF 0C		;Count-down file		
	BSF 06,7	;Take cap HIGH
Look2	NOP
	INCF 0C,1
	BTFSC 05,4	;Is input LOW?
	GOTO Look2
Look3	MOVF 0C,0	;Put file 0C into W
	MOVWF 06	;Output to 8 LEDs	
	CALL Delay2
	CALL Delay2
	CALL Delay2
	BCF 06,7	;Take cap low 
	CALL DelayA	;100mS delay
	RETURN
	

Main	CALL Look
	GOTO Main


	END		;Tells assembler end of program



