/*
 *  the main entry for the initialization routine provided by the tool
 *  chain. sta_ker() will be called to start the kernel. 
 */
int
main(void)
{
	extern void software_init_hook(void);
	void (*volatile fp)(void) = software_init_hook;

	/*
	 *  call software_init_hook if not 0.
	 *
	 *  If it's necessary to do some software enviroment initialization,
	 *  such as libray, use software_init_hook.
	 *
	 *  use volatile to omit optimization.
	 */
	if (fp != 0) {
		(*fp)();
	}

	/*
	 * start kernel
	 */
	sta_ker();

	return 1;
}
void PowerON_Reset_PC(void)
{ 
	set_intb(__sectop("C$VECT"));

#ifdef __ROZ					// Initialize FPSW
#define _ROUND 0x00000001			// Let FPSW RMbits=01 (round to zero)
#else
#define _ROUND 0x00000000			// Let FPSW RMbits=00 (round to nearest)
#endif
#ifdef __DOFF
#define _DENOM 0x00000100			// Let FPSW DNbit=1 (denormal as zero)
#else
#define _DENOM 0x00000000			// Let FPSW DNbit=0 (denormal as is)
#endif

	set_fpsw(FPSW_init | _ROUND | _DENOM);

	_INITSCT();

	_INIT_IOLIB();					// Use SIM I/O

//	errno=0;						// Remove the comment when you use errno
//	srand((_UINT)1);					// Remove the comment when you use rand()
//	_s1ptr=NULL;					// Remove the comment when you use strtok()
		
//	HardwareSetup();				// Use Hardware Setup
    nop();

//	_CALL_INIT();					// Remove the comment when you use global class object

	set_psw(PSW_init);				// Set Ubit & Ibit for PSW
//	chg_pmusr();					// Remove the comment when you need to change PSW PMbit (SuperVisor->User)

//	main();
	sta_ker();
	_CLOSEALL();					// Use SIM I/O
	
//	_CALL_END();					// Remove the comment when you use global class object

	brk();
}