#ifndef __SN8P1989__H
#define __SN8P1989__H

void _ClearWatchDogTimer(void);
void _ClrRAM(void);

#define NOP(X)  	__asm{	_NOP X }
#define LOG(X)  	__asm{	LOG CNameToAsmLabel(X) }
sfr	L = 0x80;
sfr	H = 0x81;
sfr	R = 0x82;
sfr	Z = 0x83;
sfr	Y = 0x84;
sfr	X = 0x85;
sfr	PFLAG = 0x86;
sbit	FC = 0x86:2;
sbit	FDC = 0x86:1;
sbit	FZ = 0x86:0;
sfr	RBANK = 0x87;
sbit	FRBNKS0 = 0x87:0;
sbit	FRBNKS1 = 0x87:1;
sbit	FRBNKS2 = 0x87:2;
sbit	FRBNKS3 = 0x87:3;
sfr	OPTION = 0x88;
sbit	FRCLK = 0x88:0;
#if ICE_Mode == 1
sfr	LCDM1 = 0XCB;
sbit	FLCDBNK = 0XCB:5;
sbit	FLCDENB = 0XCB:3;
sbit	FLCDBIAS = 0XCB:2;
sfr	Dummy = 0X8F;
sbit	FP2HSEG = 0X8F:1;
sbit	FP2LSEG = 0X8F:0;
#else
sfr	LCDM1 = 0x89;
sbit	FLCDBNK = 0x89:5;
sbit	FLCDENB = 0x89:3;
sbit	FLCDBIAS = 0x89:2;
sbit	FP2HSEG = 0x89:1;
sbit	FP2LSEG = 0x89:0;
#endif
sfr	AMPM = 0x90;
sbit	FBGRENB = 0x90:6;
sbit	FFDS1 = 0x90:5;
sbit	FFDS0 = 0x90:4;
sbit	FGS2 = 0x90:3;
sbit	FGS1 = 0x90:2;
sbit	FGS0 = 0x90:1;
sbit	FAMPENB = 0x90:0;
sfr	AMPCHS = 0x91;
sbit	FADC16CHS3 = 0x91:3;
sbit	FADC16CHS2 = 0x91:2;
sbit	FADC16CHS1 = 0x91:1;
sbit	FADC16CHS0 = 0x91:0;
sfr	AMPCKS = 0x92;
sfr	ADC16M = 0x93;
sbit	FIRVS = 0x93:3;
sbit	FRVS1 = 0x93:2;
sbit	FRVS0 = 0x93:1;
sbit	FADC16ENB = 0x93:0;
sfr	ADCKS = 0X94;
sfr	REGM = 0x95;
sbit	FACMENB = 0x95:7;
sbit	FAVDDRENB = 0x95:6;
sbit	FAVENB = 0x95:5;
sbit	FAVESEL1 = 0x95:4;
sbit	FAVESEL0 = 0x95:3;
sbit	FREGENB = 0x95:0;
sfr	DFM = 0x97;
sbit	FWRS0 = 0x97:2;
sbit	FDRDY = 0x97:0;
sfr	ADCDL = 0x98;
sfr	ADCDH = 0x99;
sfr	LBTM = 0x9A;
sbit	FLBTO = 0x9A:2;
sbit	FLBTENB = 0x9A:0;
sfr	BZC = 0X9B;
sfr	BZM = 0X9C;
sbit	FBZOENB = 0X9C:7;
sbit	FBZORATE2 = 0X9C:6;
sbit	FBZORATE1 = 0X9C:5;
sbit	FBZORATE0 = 0X9C:4;
sbit	FBZOX8 = 0X9C:2;
sfr	LASERM = 0X9D;
sfr	ADC12M = 0xB1;
sbit	FADC12ENB = 0xB1:7;
sbit	FADS = 0xB1:6;
sbit	FEOC = 0xB1:5;
sbit	FGCHS = 0xB1:4;
sbit	FADC12CHS1 = 0xB1:1;
sbit	FADC12CHS0 = 0xB1:0;
sfr	ADB = 0xb2;
sfr	ADR = 0xb3;
sbit	FAD12CKS1 = 0xb3:6;
sbit	FAD12CKS = 0xb3:6;
sbit	FAD12CKS0 = 0xb3:4;
sbit	FADB3 = 0xb3:3;
sbit	FADB2 = 0xb3:2;
sbit	FADB1 = 0xb3:1;
sbit	FADB0 = 0xb3:0;
sfr	PEDGE = 0xBF;
sbit	FPEDGEN = 0xBF:7;
sbit	FP00G0 = 0xBF:3;
sbit	FP00G1 = 0xBF:4;
sfr	P1W = 0xc0;
sbit	FP17W = 0xc0:7;
sbit	FP16W = 0xc0:6;
sbit	FP15W = 0xc0:5;
sbit	FP14W = 0xc0:4;
sbit	FP13W = 0xc0:3;
sbit	FP12W = 0xc0:2;
sbit	FP11W = 0xc0:1;
sbit	FP10W = 0xc0:0;
sfr	P1M = 0xC1;
sbit	FP17M = 0xC1:7;
sbit	FP16M = 0xC1:6;
sbit	FP15M = 0xC1:5;
sbit	FP14M = 0xC1:4;
sbit	FP13M = 0xC1:3;
sbit	FP12M = 0xC1:2;
sbit	FP11M = 0xC1:1;
sbit	FP10M = 0xC1:0;
sfr	P2M = 0xC2;
sbit	FP27M = 0xC2:7;
sbit	FP26M = 0xC2:6;
sbit	FP25M = 0xC2:5;
sbit	FP24M = 0xC2:4;
sbit	FP23M = 0xC2:3;
sbit	FP22M = 0xC2:2;
sbit	FP21M = 0xC2:1;
sbit	FP20M = 0xC2:0;
sfr	P5M = 0xc5;
sbit	FP57M = 0xc5:7;
sbit	FP56M = 0xc5:6;
sbit	FP55M = 0xc5:5;
sbit	FP54M = 0xc5:4;
sbit	FP53M = 0xc5:3;
sbit	FP52M = 0xc5:2;
sbit	FP51M = 0xc5:1;
sbit	FP50M = 0xc5:0;
sfr	INTRQ = 0xc8;
sbit	FTC1IRQ = 0xc8:6;
sbit	FTC0IRQ = 0xc8:5;
sbit	FT0IRQ = 0xc8:4;
sbit	FADC16IRQ = 0xc8:2;
sbit	FP01IRQ = 0xc8:1;
sbit	FP00IRQ = 0xc8:0;
sfr	INTEN = 0xc9;
sbit	FTC1IEN = 0xc9:6;
sbit	FTC0IEN = 0xc9:5;
sbit	FT0IEN = 0xc9:4;
sbit	FADC16IEN = 0xc9:2;
sbit	FP01IEN = 0xc9:1;
sbit	FP00IEN = 0xc9:0;
sfr	OSCM = 0xCA;
sbit	FWTCKS = 0xCA:7;
sbit	FWDRST = 0xCA:6;
sbit	FWDRATE = 0xCA:5;
sbit	FCPUM1 = 0xCA:4;
sbit	FCPUM0 = 0xCA:3;
sbit	FCLKMD = 0xCA:2;
sbit	FSTPHX = 0xCA:1;
sfr	TC0R = 0xCD;
sfr	PCL = 0xCE;
sfr	PCH = 0xCF;
sfr	P0 = 0xd0;
sbit	FP02 = 0xd0:2;
sbit	FP01 = 0xd0:1;
sbit	FP00 = 0xd0:0;
sfr	P1 = 0xD1;
sbit	FP17 = 0xD1:7;
sbit	FP16 = 0xD1:6;
sbit	FP15 = 0xD1:5;
sbit	FP14 = 0xD1:4;
sbit	FP13 = 0xD1:3;
sbit	FP12 = 0xD1:2;
sbit	FP11 = 0xD1:1;
sbit	FP10 = 0xD1:0;
sfr	P2 = 0xD2;
sbit	FP27 = 0xD2:7;
sbit	FP26 = 0xD2:6;
sbit	FP25 = 0xD2:5;
sbit	FP24 = 0xD2:4;
sbit	FP23 = 0xD2:3;
sbit	FP22 = 0xD2:2;
sbit	FP21 = 0xD2:1;
sbit	FP20 = 0xD2:0;
sfr	P5 = 0xD5;
sbit	FP57 = 0xD5:7;
sbit	FP56 = 0xD5:6;
sbit	FP55 = 0xD5:5;
sbit	FP54 = 0xD5:4;
sbit	FP53 = 0xD5:3;
sbit	FP52 = 0xD5:2;
sbit	FP51 = 0xD5:1;
sbit	FP50 = 0xD5:0;
sfr	T0M = 0xD8;
sbit	FT0ENB = 0xD8:7;
sbit	FT0RATE2 = 0xD8:6;
sbit	FT0RATE1 = 0xD8:5;
sbit	FT0RATE0 = 0xD8:4;
sbit	FTC1X8 = 0xD8:3;
sbit	FTC0X8 = 0xD8:2;
sbit	FTC0GN = 0xD8:1;
sbit	FT0TB = 0xD8:0;
sfr	T0C = 0xD9;
sfr	TC0M = 0xda;
sbit	FTC0ENB = 0xda:7;
sbit	FTC0RATE2 = 0xda:6;
sbit	FTC0RATE1 = 0xda:5;
sbit	FTC0RATE0 = 0xda:4;
sbit	FALOAD0 = 0xda:2;
sbit	FTC0OUT = 0xda:1;
sbit	FPWM0OUT = 0xda:0;
sfr	TC0C = 0xDB;
sfr	TC1M = 0xDC;
sbit	FTC1ENB = 0xDC:7;
sbit	FTC1RATE2 = 0xDC:6;
sbit	FTC1RATE1 = 0xDC:5;
sbit	FTC1RATE0 = 0xDC:4;
sbit	FALOAD1 = 0xDC:2;
sbit	FTC1OUT = 0xDC:1;
sbit	FPWM1OUT = 0xDC:0;
sfr	TC1C = 0xDD;
sfr	TC1R = 0xDE;
sfr	STKP = 0xDF;
sbit	FGIE = 0xDF:7;
sbit	FSTKPB3 = 0xDF:3;
sbit	FSTKPB2 = 0xDF:2;
sbit	FSTKPB1 = 0xDF:1;
sbit	FSTKPB0 = 0xDF:0;
sfr	P0UR = 0xE0;
sbit	FP01R = 0xE0:1;
sbit	FP00R = 0xE0:0;
sfr	P1UR = 0xE1;
sbit	FP17R = 0xE1:7;
sbit	FP16R = 0xE1:6;
sbit	FP15R = 0xE1:5;
sbit	FP14R = 0xE1:4;
sbit	FP13R = 0xE1:3;
sbit	FP12R = 0xE1:2;
sbit	FP11R = 0xE1:1;
sbit	FP10R = 0xE1:0;
sfr	P2UR = 0xE2;
sbit	FP27R = 0xE2:7;
sbit	FP26R = 0xE2:6;
sbit	FP25R = 0xE2:5;
sbit	FP24R = 0xE2:4;
sbit	FP23R = 0xE2:3;
sbit	FP22R = 0xE2:2;
sbit	FP21R = 0xE2:1;
sbit	FP20R = 0xE2:0;
sfr	P5UR = 0xE5;
sbit	FP57R = 0xE5:7;
sbit	FP56R = 0xE5:6;
sbit	FP55R = 0xE5:5;
sbit	FP54R = 0xE5:4;
sbit	FP53R = 0xE5:3;
sbit	FP52R = 0xE5:2;
sbit	FP51R = 0xE5:1;
sbit	FP50R = 0xE5:0;
sfr	_HL = 0xE6;
sfr	DP0X = 0xE6;
sfr	_YZ = 0xE7;
sfr	DP1X = 0xE7;
sfr	STK7L = 0xf0;
sfr	STK7H = 0xf1;
sfr	STK6L = 0xf2;
sfr	STK6H = 0xf3;
sfr	STK5L = 0xf4;
sfr	STK5H = 0xf5;
sfr	STK4L = 0xf6;
sfr	STK4H = 0xf7;
sfr	STK3L = 0xf8;
sfr	STK3H = 0xf9;
sfr	STK2L = 0xfa;
sfr	STK2H = 0xfb;
sfr	STK1L = 0xfc;
sfr	STK1H = 0xfd;
sfr	STK0L = 0xfe;
sfr	STK0H = 0xff;
#define SLEEPMODE __asm{SleepMode}
#define GREENMODE __asm{GreenMode}
#define SLOWMODE __asm{SlowMode}
#define SLOW2NORMAL __asm{Slow2Normal}
#if ICE_Mode == 1
sfr	P3M = 0xc3;
sbit	FP37M = 0xc3:7;
sbit	FP36M = 0xc3:6;
sbit	FP35M = 0xc3:5;
sbit	FP34M = 0xc3:4;
sfr	P3 = 0xD3;
sbit	FP37 = 0xD3:7;
sbit	FP36 = 0xD3:6;
sbit	FP35 = 0xD3:5;
sbit	FP34 = 0xD3:4;
sfr	P3UR = 0xE3;
sbit	FP37R = 0xE3:7;
sbit	FP36R = 0xE3:6;
sbit	FP35R = 0xE3:5;
sbit	FP34R = 0xE3:4;
#endif
#endif
