	;Expt4b.asm
        ;Project: Binary Counting up/down
	;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.
	CLRF 06		;Blank the output
	CLRF 1F		;Clear the button-press file
	GOTO Main

Delay	NOP		;Create approx 250mS delay
	DECFSZ 1A,1
	GOTO Delay
	DECFSZ 1B,1
	GOTO Delay
	RETURN


		
Main	CALL Delay	;Show LEDs for 250mS
	INCF 06,1	;Increment the count in file 6
	BTFSS 05,0	;Push-button pressed?
	GOTO MainA	;No
	BTFSS 1F,0	;Test button-press flag
	GOTO Main2	;First pass for button?
	BSF 1F,0
	GOTO Main
MainA	BCF 1F,0
	GOTO Main
	
Main2	CALL Delay	;Show LEDs for 250mS
	DECF 06		;Decrement the count in file 6
	BTFSS 05,0	;Push-button pressed?
	GOTO MainB	;No
	BTFSS 1F,0	;Test button-press flag
	GOTO Main	;First pass for button?
	BSF 1F,0
	GOTO Main2
MainB	BCF 1F,0
	GOTO Main2

	END		;Tells assembler end of program