#ifndef __SN8FMD23L__H
#define __SN8FMD23L__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	FZ = 0x86:0;
sbit	FDC = 0x86:1;
sbit	FC = 0x86:2;
sbit	FSTKOV = 0x86:4;
sbit	FRST = 0x86:5;
sbit	FWDT = 0x86:6;
sbit	FPOR = 0x86:7;
sfr	RBANK = 0x87;
sbit	FRBANKS0 = 0x87:0;
sbit	FRBANKS1 = 0x87:1;
sbit	FRBANKS2 = 0x87:2;
sfr	W0 = 0x88;
sfr	W1 = 0x89;
sfr	W2 = 0x8a;
sfr	W3 = 0x8b;
sfr	W4 = 0x8c;
sfr	W5 = 0x8d;
sfr	W6 = 0x8e;
sfr	W7 = 0x8f;
sfr	_HL = 0x90;
sfr	_YZ = 0x91;
sfr	P2OC = 0x92;
sbit	FP20OC = 0x92:0;
sbit	FP21OC = 0x92:1;
sbit	FP24OC = 0x92:4;
sbit	FP25OC = 0x92:5;
sfr	PCL = 0x93;
sfr	PCH = 0x94;
sfr	OSCM = 0x95;
sbit	FCPUM1 = 0x95:4;
sbit	FCPUM0 = 0x95:3;
sbit	FCLKMD = 0x95:2;
sbit	FSTPHX = 0x95:1;
sfr	WDTR = 0x96;
sfr	INTRQ0 = 0x97;
sbit	FCM0IRQ = 0x97:7;
sbit	FT1IRQ = 0x97:6;
sbit	FTC2IRQ = 0x97:5;
sbit	FTC1IRQ = 0x97:4;
sbit	FTC0IRQ = 0x97:3;
sbit	FT0IRQ = 0x97:2;
sbit	FP01IRQ = 0x97:1;
sbit	FP00IRQ = 0x97:0;
sfr	INTRQ1 = 0x98;
sbit	FMSPIRQ = 0x98:4;
sbit	FUTXIRQ = 0x98:3;
sbit	FURXIRQ = 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9f:3;
sbit	FP01G0 = 0x9f:2;
sbit	FP00G1 = 0x9f:1;
sbit	FP00G0 = 0x9f:0;
sfr	P0M = 0xa0;
sbit	FP07M = 0xa0:7;
sbit	FP06M = 0xa0:6;
sbit	FP05M = 0xa0:5;
sbit	FP04M = 0xa0:4;
sbit	FP03M = 0xa0:3;
sbit	FP02M = 0xa0:2;
sbit	FP01M = 0xa0:1;
sbit	FP00M = 0xa0:0;
sfr	P1M = 0xa1;
sbit	FP17M = 0xa1:7;
sbit	FP16M = 0xa1:6;
sbit	FP15M = 0xa1:5;
sbit	FP14M = 0xa1:4;
sbit	FP13M = 0xa1:3;
sbit	FP12M = 0xa1:2;
sbit	FP11M = 0xa1:1;
sbit	FP10M = 0xa1:0;
sfr	P2M = 0xa2;
sbit	FP25M = 0xa2:5;
sbit	FP24M = 0xa2:4;
sbit	FP23M = 0xa2:3;
sbit	FP22M = 0xa2:2;
sbit	FP21M = 0xa2:1;
sbit	FP20M = 0xa2:0;
sfr	P5M = 0xa5;
sbit	FP57M = 0xa5:7;
sbit	FP56M = 0xa5:6;
sbit	FP55M = 0xa5:5;
sbit	FP54M = 0xa5:4;
sbit	FP53M = 0xa5:3;
sbit	FP52M = 0xa5:2;
sbit	FP51M = 0xa5:1;
sbit	FP50M = 0xa5:0;
sfr	P0 = 0xa6;
sbit	FP07 = 0xa6:7;
sbit	FP06 = 0xa6:6;
sbit	FP05 = 0xa6:5;
sbit	FP04 = 0xa6:4;
sbit	FP03 = 0xa6:3;
sbit	FP02 = 0xa6:2;
sbit	FP01 = 0xa6:1;
sbit	FP00 = 0xa6:0;
sfr	P1 = 0xa7;
sbit	FP17 = 0xa7:7;
sbit	FP16 = 0xa7:6;
sbit	FP15 = 0xa7:5;
sbit	FP14 = 0xa7:4;
sbit	FP13 = 0xa7:3;
sbit	FP12 = 0xa7:2;
sbit	FP11 = 0xa7:1;
sbit	FP10 = 0xa7:0;
sfr	P2 = 0xa8;
sbit	FP25 = 0xa8:5;
sbit	FP24 = 0xa8:4;
sbit	FP23 = 0xa8:3;
sbit	FP22 = 0xa8:2;
sbit	FP21 = 0xa8:1;
sbit	FP20 = 0xa8:0;
sfr	P5 = 0xab;
sbit	FP57 = 0xab:7;
sbit	FP56 = 0xab:6;
sbit	FP55 = 0xab:5;
sbit	FP54 = 0xab:4;
sbit	FP53 = 0xab:3;
sbit	FP52 = 0xab:2;
sbit	FP51 = 0xab:1;
sbit	FP50 = 0xab:0;
sfr	P0UR = 0xac;
sbit	FP00R = 0xac:0;
sbit	FP01R = 0xac:1;
sbit	FP02R = 0xac:2;
sbit	FP03R = 0xac:3;
sbit	FP04R = 0xac:4;
sbit	FP05R = 0xac:5;
sbit	FP06R = 0xac:6;
sbit	FP07R = 0xac:7;
sfr	P1UR = 0xad;
sbit	FP10R = 0xad:0;
sbit	FP11R = 0xad:1;
sbit	FP12R = 0xad:2;
sbit	FP13R = 0xad:3;
sbit	FP14R = 0xad:4;
sbit	FP15R = 0xad:5;
sbit	FP16R = 0xad:6;
sbit	FP17R = 0xad:7;
sfr	P2UR = 0xae;
sbit	FP20R = 0xae:0;
sbit	FP21R = 0xae:1;
sbit	FP22R = 0xae:2;
sbit	FP23R = 0xae:3;
sbit	FP24R = 0xae:4;
sbit	FP25R = 0xae:5;
sfr	P5UR = 0xb1;
sbit	FP50R = 0xb1:0;
sbit	FP51R = 0xb1:1;
sbit	FP52R = 0xb1:2;
sbit	FP53R = 0xb1:3;
sbit	FP54R = 0xb1:4;
sbit	FP55R = 0xb1:5;
sbit	FP56R = 0xb1:6;
sbit	FP57R = 0xb1:7;
sfr	T0M = 0xb2;
sbit	FT0ENB = 0xb2:7;
sbit	FT0RATE2 = 0xb2:6;
sbit	FT0RATE1 = 0xb2:5;
sbit	FT0RATE0 = 0xb2:4;
sbit	FT0TB = 0xb2:0;
sfr	T0C = 0xb3;
sfr	TC0M = 0xb4;
sbit	FTC0ENB = 0xb4:7;
sbit	FTC0RATE2 = 0xb4:6;
sbit	FTC0RATE1 = 0x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:6;
sbit	FSRATE1 = 0xe0:5;
sbit	FSRATE0 = 0xe0:4;
sbit	FMLSB = 0xe0:3;
sbit	FSCKMD = 0xe0:2;
sbit	FCPOL = 0xe0:1;
sbit	FCPHA = 0xe0:0;
sfr	SIOR = 0xe1;
sfr	SIOB = 0xe2;
sfr	URTX = 0xe4;
sbit	FUTXEN = 0xe4:7;
sbit	FUTXPEN = 0xe4:6;
sbit	FUTXPS = 0xe4:5;
sbit	FUTXBRK = 0xe4:4;
sbit	FURXBZ = 0xe4:3;
sbit	FUTXBZ = 0xe4:2;
sfr	URRX = 0xe5;
sbit	FURXEN = 0xe5:7;
sbit	FURXPEN = 0xe5:6;
sbit	FURXPS = 0xe5:5;
sbit	FURXPC = 0xe5:4;
sbit	FUFMER = 0xe5:3;
sbit	FURS2 = 0xe5:2;
sbit	FURS1 = 0xe5:1;
sbit	FURS0 = 0xe5:0;
sfr	URCR = 0xe6;
sfr	UTXD = 0xe7;
sfr	URXD = 0xe8;
sfr	MSPSTAT = 0xea;
sbit	FCKE = 0xea:6;
sbit	FD_A = 0xea:5;
sbit	FP = 0xea:4;
sbit	FS = 0xea:3;
sbit	FRED_WRT = 0xea:2;
sbit	FBF = 0xea:0;
sfr	MSPM1 = 0xeb;
sbit	FWCOL = 0xeb:7;
sbit	FMSPOV = 0xeb:6;
sbit	FMSPENB = 0xeb:5;
sbit	FCKP = 0xeb:4;
sbit	FSLRXCKP = 0xeb:3;
sbit	FMSPWK = 0xeb:2;
sbit	FMSPC = 0xeb:0;
sfr	MSPM2 = 0xec;
sbit	FGCEN = 0xec:7;
sbit	FACKSTAT = 0xec:6;
sbit	FACKDT = 0xec:5;
sbit	FACKEN = 0xec:4;
sbit	FRCEN = 0xec:3;
sbit	FPEN = 0xec:2;
sbit	FRSEN = 0xec:1;
sbit	FSEN = 0xec:0;
sfr	MSPBUF = 0xed;
sbit	FMSPBUF7 = 0xed:7;
sbit	FMSPBUF6 = 0xed:6;
sbit	FMSPBUF5 = 0xed:5;
sbit	FMSPBUF4 = 0xed:4;
sbit	FMSPBUF3 = 0xed:3;
sbit	FMSPBUF2 = 0xed:2;
sbit	FMSPBUF1 = 0xed:1;
sbit	FMSPBUF0 = 0xed:0;
sfr	MSPADR = 0xee;
sbit	FMSPADR7 = 0xee:7;
sbit	FMSPADR6 = 0xee:6;
sbit	FMSPADR5 = 0xee:5;
sbit	FMSPADR4 = 0xee:4;
sbit	FMSPADR3 = 0xee:3;
sbit	FMSPADR2 = 0xee:2;
sbit	FMSPADR1 = 0xee:1;
sbit	FMSPADR0 = 0xee:0;
sfr	STKP = 0xef;
sbit	FGIE = 0xef:7;
sbit	FLVD24 = 0xef:6;
sbit	FLVD33 = 0xef:5;
sbit	FSTKPB2 = 0xef:2;
sbit	FSTKPB1 = 0xef:1;
sbit	FSTKPB0 = 0xef:0;
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}
#endif
