/********************************************************************

	Generate_runtime_errors.c
	Z-World, 2001

This program generates run-time errors that  
can be displayed with DISPLAY_ERRORLOG.C.

1) Make sure ENABLE_ERROR_LOGGING at the top of the
   RabbitBIOS.c is #defined to 1.

2) Uncomment the type of error you wish to generate.

3) Compile this program to flash.

4) Disconnect the programming cable from the target

5) Cycle power on the board or hit the reset button if
   it has one.

6) Wait a moment, then reconnect the programming cable.

7) Compile DISPLAY_ERRORLOG.C and run it to see the
   display of the error log.

 ********************************************************************/
#class auto

//**** Uncomment the type of error you wish to generate
//#define DIVIDE_ZERO
//#define RANGE
#define DOMAIN
//#define BAD_INTERRUPT
//#define BAD_XALLOC
//#define VIRTUAL_WD_TIMEOUT
//#define POINTER       // Pointer checking must be enabled in compiler options
//#define ARRAY_BOUNDS  // Must be enabled in compiler options
 
#define	MAXARRAYSIZE	5

void main()
{
	int	*ip, j;
	float	f;
	char	mystr[MAXARRAYSIZE];

#ifdef DIVIDE_ZERO
	j = 0;
	j = 234/j;
#endif

#ifdef RANGE
	f = fmod(1, 0);
#endif

#ifdef DOMAIN
	f = acos(2);
#endif
				
#ifdef BAD_INTERRUPT
	asm rst	10h
#endif

#ifdef BAD_XALLOC
	xalloc(0xFFFFFFFF);
#endif

#ifdef VIRTUAL_WD_TIMEOUT
	j  = VdGetFreeWd(3);  // allocate a VWD
	while(1);             // and never hit it
#endif

#ifdef POINTER
	ip = (int *)0x0000;
	*ip = 4;
#endif
				
#ifdef ARRAY_BOUNDS
	j = MAXARRAYSIZE+10;
	mystr[j] = 'Q';
#endif

}

