;**********************************************************************
	list		p=16f877A	; list directive to define processor
	#include	<p16f877A.inc>	; processor specific variable definitions
	
	__CONFIG 0x3f32

; '__CONFIG' directive is used to embed configuration data within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.
;	errorlevel -302


;***** VARIABLE DEFINITIONS
w_temp		EQU	0x71		; variable used for context saving 
status_temp	EQU	0x72		; variable used for context saving
tmp1		equ	0x73
tmp2		equ	0x74			
;**********************************************************************
	ORG     0x000             ; processor reset vector

	clrf    PCLATH            ; ensure page bits are cleared
  	goto    main              ; go to beginning of program


	ORG     0x004             ; interrupt vector location

	movwf   w_temp            ; save off current W register contents
	movf	STATUS,w          ; move status register into W register
	movwf	status_temp       ; save off contents of STATUS register


; isr code can go here or be located as a call subroutine elsewhere
	bcf		INTCON,T0IF		; clr flag T0IF
	movlw	0xff				; PORTC  =  !PORTC
	xorwf	PORTC,f
; interupt code here !!!!!!!!!!!!!!!!!

	movf    status_temp,w     ; retrieve copy of STATUS register
	movwf	STATUS           	; restore pre-isr STATUS register contents
	swapf   w_temp,f
	swapf   w_temp,w          ; restore pre-isr W register contents
	retfie                    		; return from interrupt

main

; remaining code goes here
		
	bsf		STATUS,RP0
	movlw	0x06
	movwf	ADCON1	
	clrf		TRISA
	clrf		TRISB
	clrf		TRISC
	clrf		tmp1
	clrf		tmp2
	movlw	0x87			; tmr0 prescal 1:256
	movwf	OPTION_REG
	movlw	b'10100000'		; timer0 intr enable 
	movwf	INTCON

	bcf		STATUS,RP0
	bcf		ADCON0,ADON
	clrf		PORTC
et1
	clrw
	movwf	PORTA
	movwf	PORTB
	call		delay
	movlw	0xff
	movwf	PORTA
	movwf	PORTB
	call		delay
	goto	et1

delay
	decfsz	tmp1,f
	goto	delay
	decfsz	tmp2,f
	goto	delay
	return	

	END                       ; directive 'end of program'

