;	gpasm -a inhx8m timer0.asm
;	Port 2 ON/OFF
;	DB Henrik Kressner



processor	10F322
include		p10f322.inc

	__CONFIG _WDTE_OFF & _FOSC_INTOSC

	org	H'00'  	; Reset vector
	goto	setup
	org	0x04	; Interrupt vector
	goto	intr

	org	H'05'
setup	clrf    ANSELA          ; All ports are digital I/O
	movlw	B'11111011'
	movwf	TRISA		; Port 2 is output
	movlw	B'00000111'	; Fosc/4 and PSA on and 1:256
	movwf	OPTION_REG	; Prescaler settings
	movlw	B'10100000'	; GEI and TMR0IE
	movwf	INTCON

run	goto	run

intr	bcf	INTCON, TMR0IF	; Enable interrupt
;	movlw	0x0f		; Optional
;	movwf	TMR0		; Optional
	btfsc	PORTA, RA2	; What’s on port 2
	goto	off
	goto	on

off	bcf	PORTA, RA2
	RETFIE

on	bsf 	PORTA, RA2
	RETFIE

	end

