#ifndef	_PICME_H
#define	_PICME_H

#if defined(_16C57)
	#include	<pic165x.h>
#endif

#if defined(_16C67)
	#include	<pic166x.h>
#endif
	
#if defined(_16F77)
	#include	<pic16f7x.h>
#endif
	
#if defined(_16F877)
	#include	<pic1687x.h>
#endif

#define	CLRWDT()	asm(" clrwdt")
#define	SLEEP()		asm(" sleep")

#define	___mkstr1(x)	#x
#define	___mkstr(x)	___mkstr1(x)
#define	__CONFIG(x)	asm("\tpsect config,class=CODE,delta=2");\
			asm("\tglobal\tconfig_word"); \
			asm("config_word"); \
			asm("\tdw "___mkstr(x))

#define __IDLOC(w)       asm("\tpsect idloc,class=CODE,delta=2");\
			 asm("\tglobal\tidloc_word"); \
			 asm("idloc_word"); \
			 asm("\tirpc\t__arg," ___mkstr(w)); \
			 asm("\tdw 0&__arg&h"); \
			 asm("\tendm")
   	                 
#define __EEPROM_DATA(a, b, c, d, e, f, g, h) \
			 asm("\tpsect eeprom_data,class=CODE,delta=2"); \
			 asm("\tdb\t" ___mkstr(a) "," ___mkstr(b) "," ___mkstr(c) "," ___mkstr(d) "," \
				      ___mkstr(e) "," ___mkstr(f) "," ___mkstr(g) "," ___mkstr(h))

// global interrupt enable macros

#ifdef _PIC16

#ifndef	ei
#define	ei()	(GLINTD = 0)	// interrupt disable bit
#endif  ei

#ifndef	di
#define	di()	(GLINTD = 1)	// interrupt disable bit
#endif di

#elif defined _PIC14
	
#ifndef	ei
#define	ei()	(GIE = 1)	// interrupt enable bit
#endif  ei

#ifndef	di
#define	di()	(GIE = 0)	// interrupt enable bit
#endif  di
			 
#endif
#endif	/* _PICME_H */
