	;Expt4e.asm
        ;Project: Push "A" to display a word
	;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		
	BCF 03,5	;Go to Bank 0 - the program memory area.	
	CLRF 1F		;Clear the button-press file
	GOTO Main

Table1	ADDWF 02h,1	;Add W to the Program Counter to create a jump. 
	RETLW 79h	;E    This is jump=0 location.   format= gfedcba
	RETLW 37h	;N    This is jump=1 location.
	RETLW 78h	;t    This is jump=2 location.
	RETLW 79h	;E
	RETLW 50h	;r	
	RETLW 00h	;blank

Delay	NOP		;Create approx 250mS delay
	DECFSZ 1A,1
	GOTO Delay
	DECFSZ 1B,1
	GOTO Delay
	RETURN

Sw	BTFSS 05,0	;Test the push-button input
	RETURN		;Sw NOT pushed
	BSF 1F,0	;Switch pushed. Set button flag.
	RETURN

Word1	MOVF 1E,0	;Copy the jump-value into W
	CALL Table1	;W will return with display-value
	MOVWF 06	;Output display value
	CALL Delay	;Display for 0.25sec
	CALL Delay	;Display for 0.25sec
	CALL Delay	;Display for 0.25sec
	CLRF 06		;Clear the display
	CALL Delay	;Display for 0.25sec
	INCF 1E,1	;Increment jump-value to look at next table value
	MOVLW 06h	;The number of table-values (in hex)
	XORWF 1E,0	;Has the jump-value reached 06h?
	BTFSS 03,2	;Test the zero bit in the Status register
	GOTO Word1	;Loop to display next table-value
	RETURN		;Start again

		
Main	CLRF 1E		;File 1E holds the jump-value for the table
	CALL Sw		;Poll (look at) push-button "A"
	BTFSC 1F,0	;Has switch been pushed?
	CALL Word1	;Yes. Display "ENtEr"
	BCF 1F,0	;Clear button flag
	GOTO Main

	END		;Tells assembler end of program
