#include <stdio.h>
#include <HC11.H>

int count;
/**************************************************/
/* buff_vec.c                                     */
/*                                                */
/* D. Bridges                                     */
/* October 27, 2000                               */
/*                                                */
/* Structure initilization of Buffalo's           */
/* interrupt vector jump table for the Imagecraft */
/* ICC11 compiler.                                */
/*                                                */
/* This file should be included anytime interrupt */
/* service routines are being used while running  */
/* under the Buffalo operating system.            */
/*                                                */
/* Because it does not include any of the extern  */
/* interrupt service routines, or a "main" module,*/
/* this file will not compile into an executable  */
/* by itself.  It must either be compiled as to   */
/* an "object" file (to be linked with other      */
/* object files later), or included as a file in  */
/* project that has the ISRs and "main" defined.  */
/*                                                */
/* Any ISRs that are used must be declared as     */
/* "extern" in this file.  The DUMMY_ENTRY        */
/* should be used for all vectors not being used. */
/*                                                */
/* This file is initially set up to define jump   */
/* table addresses for RTI, IRQ and SWI.          */                         
/*                                                */
/**************************************************/

/* Buffalo's interrupt vector jump table for */
/* the 68HC11 has 20 entries in it.          */
#define NUM_VEC 20
#define DUMMY_ENTRY (void (*)()) 0xF000

extern void _start();
extern void RTI_ISR();
extern void IRQ_ISR();
extern void SWI_ISR();

//#define INTR_ON()   asm("  cli")
//#define INTR_OFF()  asm("  sei")

typedef const struct I_VEC_JMP_TBL
{
   unsigned char jmp_instr;
   void (*isr_addr)();
} jmp_tbl;

#pragma abs_address:0x00c4
jmp_tbl IVJT[NUM_VEC] =
{
   {0x7e,DUMMY_ENTRY},  // SCI
   {0x7e,DUMMY_ENTRY},	// SPI
   {0x7e,DUMMY_ENTRY},	// Pulse Accumulator Input Edge
   {0x7e,DUMMY_ENTRY},	// Pulse Accumulator Overflow
   {0x7e,DUMMY_ENTRY},	// Timer Overflow
   {0x7e,DUMMY_ENTRY},	// Timer Output Compare 5
   {0x7e,DUMMY_ENTRY},	// Timer Output Compare 4
   {0x7e,DUMMY_ENTRY},	// Timer Output Compare 3
   {0x7e,DUMMY_ENTRY},	// Timer Output Compare 2
   {0x7e,DUMMY_ENTRY},	// Timer Output Compare 1
   {0x7e,DUMMY_ENTRY},	// Timer Input Capture 3
   {0x7e,DUMMY_ENTRY},	// Timer Input Capture 2
   {0x7e,DUMMY_ENTRY},	// Timer Input Capture 1
   {0x7e,RTI_ISR},		// RTI
   {0x7e,IRQ_ISR},		// IRQ
   {0x7e,DUMMY_ENTRY},	// XIRQ   	   
   {0x7e,SWI_ISR},		// SWI
   {0x7e,DUMMY_ENTRY},	// Illegal Opcode   	   
   {0x7e,DUMMY_ENTRY},	// COP
   {0x7e,DUMMY_ENTRY},	// Clock Monitor   	   
   
};
#pragma end_abs_address

/**************************************************/
/* isr_pgms.c                                     */
/*                                                */
/* D. Bridges                                     */
/* October 27, 2000                               */
/*                                                */
/* Skeleton code for a c file where all of the    */
/* interrupt service routines are defined.        */
/*                                                */
/* When compiling, this file should be accompanied*/
/* by buff_vec.c (for running under Buffalo), or  */
/* rom_vec.c (for running without Buffalo).       */
/*                                                */
/* Because it does not include a "main" module,   */
/* this file will not compile into an executable  */
/* by itself.  It must either be compiled as to   */
/* an "object" file (to be linked with other      */
/* object files later), or included as a file in  */
/* project that has "main" code defined.          */
/*                                                */
/**************************************************/

#pragma interrupt_handler RTI_ISR()
void RTI_ISR(void)
{
 	 TFLG2=0x40;
	 count=count+1;
	 if (count==31)
	 {
	      printf("*");
		  count = 0;
     }
}

#pragma interrupt_handler IRQ_ISR()
void IRQ_ISR(void)
{
}

#pragma interrupt_handler SWI_ISR()
void SWI_ISR(void)
{
}

void main (void)
{
  INTR_ON();
  TFLG2=0x40;
  TMSK2=0x40;
  PACTL=0x03;
  while (1);
}