**********************************************************************
* IRQ Interrupt Example          EEL-4744              EMS & AAA *
*
* Counts up to 65535 pulses
**********************************************************************
* EQUATEs
**********************************************************************
Bit0	EQU	%00000001
REGS	EQU	$1000
RAM	EQU	$0000
RAMEND	EQU	$01FF
IPV_IRQ	EQU	$00EE
EEPROM	EQU	$B600
PORTB	EQU	$0004
**********************************************************************
* Data Section
**********************************************************************
	ORG	RAM
CNTR16	RMB	2	; Could use ZMB 2 or FCB 0,0
**********************************************************************
* Interrupt Pseudo-Vector Initialization (to run on EVBU)
**********************************************************************
	ORG	IPV_IRQ
	JMP	IRQ_ISR
**********************************************************************
* Main Program
**********************************************************************
	ORG	EEPROM
**********************************************************************
* Initialization Section
**********************************************************************
	LDS	#RAMEND	; Initialize the stack pointer, SP
	LDD	#0	; Clear 16-bit D register
	STD	CNTR16	; Take the responsibility for clearing counter
**********************************************************************
* Setup each hardware device
**********************************************************************
* Initialize the IRQ FF to zero using the Pre-Clear input on PB0
	LDX	#REGS	
	BCLR	PORTB,X Bit0	; Set PB0=0, i.e., pre-clear FF
	BSET	PORTB,X Bit0	; Turn off pre-clear input
**********************************************************************
* Main program does its work here
**********************************************************************
	CLI			; Turn interrupt system on
HERE	BRA	HERE		; Main program waits on interrupts
*
**********************************************************************
* Interrupt Service Routine(s)
**********************************************************************
*	Part I : Service the interrupt
**********************************************************************
IRQ_ISR LDD	CNTR16		; Obtain current count
	ADDD	#1		; Increment the count
	STD	CNTR16		; Store the current count
**********************************************************************
*	Part II : Clear the interrupt flag
**********************************************************************
*	LDAA	#%00000000	; Turn off PB0 to pre-clear the FF
*	STAA	PORTB		;   ...
*	LDAA	#%00000001  	; Turn off pre-clear input; could use INCA
*	STAA	PORTB		; FF ready for next switch depression
	LDX	#REGS	
	BCLR	PORTB,X Bit0	; Set PB0=0, i.e., pre-clear FF
	BSET	PORTB,X Bit0	; Turn off pre-clear input
	RTI			; Return from Interrupt Service
