	;Expt8a.asm
        ;Project: Resistance Scale:0-9
	;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

Table	ADDWF 02h,1	;Add W to the Program Counter to create a jump.
	RETLW 3Fh	;0    format= gfedcba
	RETLW 06h	;1    If any table value has a leading letter, it must be
	RETLW 5Bh	;2    preceded with a "0."   E.g: 0A3h, 0FFh, 0CCh
	RETLW 4Fh	;3
	RETLW 66h	;4
	RETLW 6Dh	;5
	RETLW 7Dh	;6
	RETLW 07h	;7
	RETLW 7Fh	;8
	RETLW 6Fh	;9
	RETLW 40h	;"-" overflow

Delay	MOVLW 80h	;Create 100mS delay
	MOVWF 1B		
DelayA	DECFSZ 1A,1
	GOTO DelayA
	DECFSZ 1B,1
	GOTO DelayA
	RETURN

Delay2	MOVLW 20h	;Create "Look" delay
	MOVWF 1A		
DelayB	DECFSZ 1A,1
	GOTO DelayB	
	RETURN

Look	CLRF 0C		;Count-down file		
	BSF 06,7	;Take cap HIGH
Look2	CALL Delay2	
	BTFSS 05,4	;Is input LOW?
	GOTO Look3
	INCF 0C,1
	GOTO Look2
Look3	MOVF 0C,0	;Put file 0C into W
	CALL Table		
	MOVWF 06	;Output to 7-Segment display
	CALL Delay	
	BCF 06,7	;Take cap low 
	CALL Delay	;100mS delay
	RETURN	

Main	CALL Look
	GOTO Main


	END		;Tells assembler end of program



