
/* Trivial program to flash an led on PORT B bit 5,
   with some places to insert breakpoints and watchpoints
   to demonstrate GDB
*/

#define PBIOR (*(volatile short int *)(0x5ffffc6))
#define PBCR1 (*(volatile short int *)(0x5ffffcc))
#define PBCR2 (*(volatile short int *)(0x5ffffce))
#define PBDR  (*(volatile short int *)(0x5ffffc2))

#define DELAY 20

int count = 0;

void init() {
  /* asm( ".global _init" ); */
asm ("mov.l  stack_loc,r15");
main();

asm (".align 2");
asm( "stack_loc: .long _stack_top" );


}

main()
{
  int i;
  int j = 0;

  PBIOR |= 0x0020;
  PBCR2 &= ~0x0C00;

  while (1) 
    {
      /* somewhere (j++); */
      
      for (i = 0; i < 10; i++) 
	{
	  /* Toggle the light */
	  PBDR ^= 0x0020;
	  sleep (DELAY); 
	}
    }
}

dummy()
{
  count++;
}

void edata (void)
{
} /* end - edata */

somewhere (x)
{
  count += x;
}

sleep (int delay)
{
  int i;
  int j;
  for (j = 0; j < 1000; j++)
    for (i = 0; i < delay; i++)
      dummy();
}

int __main() {}    /* now required by compiler; see release notes */


