* device/lib/pic/libdev/*.c
[fw/sdcc] / device / include / pic / pic16f877.h
index 325e1364f53d63228e581dc62cc079ce793f3dfa..6805f234be6b847ac714196dec009171ad66e794 100644 (file)
-/*
-
-Small Device C Compiler (SDCC) - PIC16F877 Device Library Header 2004
-
-Note an alterative header file can be generated from 
-inc files using peal script support/scripts/inc2h.pl
-
-*/
-
-#ifndef PIC16F877_H
-#define PIC16F877_H
-
-
-/*****************************************************************************
-       RAM
- *****************************************************************************/
-
-#pragma maxram 0x1FF
-
-#pragma memmap 0x0020 0x006f RAM 0x000
-#pragma memmap 0x0070 0x007f RAM 0x180
-#pragma memmap 0x00a0 0x00ef RAM 0x000
-#pragma memmap 0x0110 0x016f RAM 0x000
-#pragma memmap 0x0190 0x01ef RAM 0x000
-
-
-/*****************************************************************************
-       Special Function Register Addresses
- *****************************************************************************/
-
-enum {
-       indf_addr       = 0x0000,
-       tmr0_addr       = 0x0001,
-       pcl_addr        = 0x0002,
-       status_addr     = 0x0003,
-       fsr_addr        = 0x0004,
-       porta_addr      = 0x0005,
-       portb_addr      = 0x0006,
-       portc_addr      = 0x0007,
-       portd_addr      = 0x0008,
-       porte_addr      = 0x0009,
-       pclath_addr     = 0x000a,
-       intcon_addr     = 0x000b,
-       pir1_addr       = 0x000c,
-       pir2_addr       = 0x000d,
-       tmr1l_addr      = 0x000e,
-       tmr1h_addr      = 0x000f,
-       t1con_addr      = 0x0010,
-       tmr2_addr       = 0x0011,
-       t2con_addr      = 0x0012,
-       sspbuf_addr     = 0x0013,
-       sspcon_addr     = 0x0014,
-       ccpr1l_addr     = 0x0015,
-       ccpr1h_addr     = 0x0016,
-       ccp1con_addr    = 0x0017,
-       rcsta_addr      = 0x0018,
-       txreg_addr      = 0x0019,
-       rcreg_addr      = 0x001a,
-       ccpr2l_addr     = 0x001b,
-       ccpr2h_addr     = 0x001c,
-       ccp2con_addr    = 0x001d,
-       adresh_addr     = 0x001e,
-       adcon0_addr     = 0x001f,
-       option_reg_addr = 0x0081,
-       trisa_addr      = 0x0085,
-       trisb_addr      = 0x0086,
-       trisc_addr      = 0x0087,
-       trisd_addr      = 0x0088,
-       trise_addr      = 0x0089,
-       pie1_addr       = 0x008c,
-       pie2_addr       = 0x008d,
-       pcon_addr       = 0x008e,
-       sspcon2_addr    = 0x0091,
-       pr2_addr        = 0x0092,
-       sspadd_addr     = 0x0093,
-       sspstat_addr    = 0x0094,
-       txsta_addr      = 0x0098,
-       spbrg_addr      = 0x0099,
-       adresl_addr     = 0x009e,
-       adcon1_addr     = 0x009f,
-       eedata_addr     = 0x010c,
-       eeadr_addr      = 0x010d,
-       eedath_addr     = 0x010e,
-       eeadrh_addr     = 0x010f,
-       eecon1_addr     = 0x018c,
-       eecon2_addr     = 0x018d,
-       config_addr     = 0x2007
-};
-
-/* Special function register memory map - memmap start_addr end_addr type bank_mask */
-#pragma memmap 0x001 0x001 SFR 0x080
-#pragma memmap 0x002 0x004 SFR 0x180
-#pragma memmap 0x005 0x005 SFR 0x000
-#pragma memmap 0x006 0x006 SFR 0x080
-#pragma memmap 0x007 0x009 SFR 0x000
-#pragma memmap 0x00a 0x00b SFR 0x180
-#pragma memmap 0x00c 0x01f SFR 0x000
-#pragma memmap 0x081 0x081 SFR 0x100
-#pragma memmap 0x085 0x085 SFR 0x000
-#pragma memmap 0x086 0x086 SFR 0x100
-#pragma memmap 0x087 0x089 SFR 0x000
-#pragma memmap 0x08c 0x08e SFR 0x000
-#pragma memmap 0x091 0x094 SFR 0x000
-#pragma memmap 0x098 0x099 SFR 0x000
-#pragma memmap 0x09c 0x09f SFR 0x000
-#pragma memmap 0x10c 0x10f SFR 0x000
-#pragma memmap 0x18c 0x18d SFR 0x000
-
-
-/*****************************************************************************
-       Misc Registers
- *****************************************************************************/
-
-/* ---- STATUS Bits -------------------------------------------------------- */
+//
+// Register Declarations for Microchip 16F877 Processor
+//
+//
+// This header file was automatically generated by:
+//
+//     inc2h.pl V4585
+//
+//     Copyright (c) 2002, Kevin L. Pauba, All Rights Reserved
+//
+//     SDCC is licensed under the GNU Public license (GPL) v2.  Note that
+//     this license covers the code to the compiler and other executables,
+//     but explicitly does not cover any code or objects generated by sdcc.
+//     We have not yet decided on a license for the run time libraries, but
+//     it will not put any requirements on code linked against it. See:
+// 
+//     http://www.gnu.org/copyleft/gpl/html
+//
+//     See http://sdcc.sourceforge.net/ for the latest information on sdcc.
+//
+// 
+#ifndef P16F877_H
+#define P16F877_H
+
+//
+// Register addresses.
+//
+#define INDF_ADDR      0x0000
+#define TMR0_ADDR      0x0001
+#define PCL_ADDR       0x0002
+#define STATUS_ADDR    0x0003
+#define FSR_ADDR       0x0004
+#define PORTA_ADDR     0x0005
+#define PORTB_ADDR     0x0006
+#define PORTC_ADDR     0x0007
+#define PORTD_ADDR     0x0008
+#define PORTE_ADDR     0x0009
+#define PCLATH_ADDR    0x000A
+#define INTCON_ADDR    0x000B
+#define PIR1_ADDR      0x000C
+#define PIR2_ADDR      0x000D
+#define TMR1L_ADDR     0x000E
+#define TMR1H_ADDR     0x000F
+#define T1CON_ADDR     0x0010
+#define TMR2_ADDR      0x0011
+#define T2CON_ADDR     0x0012
+#define SSPBUF_ADDR    0x0013
+#define SSPCON_ADDR    0x0014
+#define CCPR1L_ADDR    0x0015
+#define CCPR1H_ADDR    0x0016
+#define CCP1CON_ADDR   0x0017
+#define RCSTA_ADDR     0x0018
+#define TXREG_ADDR     0x0019
+#define RCREG_ADDR     0x001A
+#define CCPR2L_ADDR    0x001B
+#define CCPR2H_ADDR    0x001C
+#define CCP2CON_ADDR   0x001D
+#define ADRESH_ADDR    0x001E
+#define ADCON0_ADDR    0x001F
+#define OPTION_REG_ADDR        0x0081
+#define TRISA_ADDR     0x0085
+#define TRISB_ADDR     0x0086
+#define TRISC_ADDR     0x0087
+#define TRISD_ADDR     0x0088
+#define TRISE_ADDR     0x0089
+#define PIE1_ADDR      0x008C
+#define PIE2_ADDR      0x008D
+#define PCON_ADDR      0x008E
+#define SSPCON2_ADDR   0x0091
+#define PR2_ADDR       0x0092
+#define SSPADD_ADDR    0x0093
+#define SSPSTAT_ADDR   0x0094
+#define TXSTA_ADDR     0x0098
+#define SPBRG_ADDR     0x0099
+#define ADRESL_ADDR    0x009E
+#define ADCON1_ADDR    0x009F
+#define EEDATA_ADDR    0x010C
+#define EEADR_ADDR     0x010D
+#define EEDATH_ADDR    0x010E
+#define EEADRH_ADDR    0x010F
+#define EECON1_ADDR    0x018C
+#define EECON2_ADDR    0x018D
+
+//
+// Memory organization.
+//
+
+
+
+//         LIST
+// P16F877.INC  Standard Header File, Version 1.00    Microchip Technology, Inc.
+//         NOLIST
+
+// This header file defines configurations, registers, and other useful bits of
+// information for the PIC16F877 microcontroller.  These names are taken to match 
+// the data sheets as closely as possible.  
+
+// Note that the processor must be selected before this file is 
+// included.  The processor may be selected the following ways:
+
+//       1. Command line switch:
+//               C:\ MPASM MYFILE.ASM /PIC16F877
+//       2. LIST directive in the source file
+//               LIST   P=PIC16F877
+//       3. Processor Type entry in the MPASM full-screen interface
+
+//==========================================================================
+//
+//       Revision History
+//
+//==========================================================================
+
+//Rev:   Date:    Reason:
+
+//1.12   01/12/00 Changed some bit names, a register name, configuration bits
+//                 to match datasheet (DS30292B)
+//1.00   08/07/98 Initial Release
+
+//==========================================================================
+//
+//       Verify Processor
+//
+//==========================================================================
+
+//        IFNDEF __16F877
+//            MESSG "Processor-header file mismatch.  Verify selected processor."
+//         ENDIF
+
+//==========================================================================
+//
+//       Register Definitions
+//
+//==========================================================================
+
+#define W                    0x0000
+#define F                    0x0001
+
+//----- Register Files------------------------------------------------------
+
+extern __sfr  __at (INDF_ADDR)                    INDF;
+extern __sfr  __at (TMR0_ADDR)                    TMR0;
+extern __sfr  __at (PCL_ADDR)                     PCL;
+extern __sfr  __at (STATUS_ADDR)                  STATUS;
+extern __sfr  __at (FSR_ADDR)                     FSR;
+extern __sfr  __at (PORTA_ADDR)                   PORTA;
+extern __sfr  __at (PORTB_ADDR)                   PORTB;
+extern __sfr  __at (PORTC_ADDR)                   PORTC;
+extern __sfr  __at (PORTD_ADDR)                   PORTD;
+extern __sfr  __at (PORTE_ADDR)                   PORTE;
+extern __sfr  __at (PCLATH_ADDR)                  PCLATH;
+extern __sfr  __at (INTCON_ADDR)                  INTCON;
+extern __sfr  __at (PIR1_ADDR)                    PIR1;
+extern __sfr  __at (PIR2_ADDR)                    PIR2;
+extern __sfr  __at (TMR1L_ADDR)                   TMR1L;
+extern __sfr  __at (TMR1H_ADDR)                   TMR1H;
+extern __sfr  __at (T1CON_ADDR)                   T1CON;
+extern __sfr  __at (TMR2_ADDR)                    TMR2;
+extern __sfr  __at (T2CON_ADDR)                   T2CON;
+extern __sfr  __at (SSPBUF_ADDR)                  SSPBUF;
+extern __sfr  __at (SSPCON_ADDR)                  SSPCON;
+extern __sfr  __at (CCPR1L_ADDR)                  CCPR1L;
+extern __sfr  __at (CCPR1H_ADDR)                  CCPR1H;
+extern __sfr  __at (CCP1CON_ADDR)                 CCP1CON;
+extern __sfr  __at (RCSTA_ADDR)                   RCSTA;
+extern __sfr  __at (TXREG_ADDR)                   TXREG;
+extern __sfr  __at (RCREG_ADDR)                   RCREG;
+extern __sfr  __at (CCPR2L_ADDR)                  CCPR2L;
+extern __sfr  __at (CCPR2H_ADDR)                  CCPR2H;
+extern __sfr  __at (CCP2CON_ADDR)                 CCP2CON;
+extern __sfr  __at (ADRESH_ADDR)                  ADRESH;
+extern __sfr  __at (ADCON0_ADDR)                  ADCON0;
+
+extern __sfr  __at (OPTION_REG_ADDR)              OPTION_REG;
+extern __sfr  __at (TRISA_ADDR)                   TRISA;
+extern __sfr  __at (TRISB_ADDR)                   TRISB;
+extern __sfr  __at (TRISC_ADDR)                   TRISC;
+extern __sfr  __at (TRISD_ADDR)                   TRISD;
+extern __sfr  __at (TRISE_ADDR)                   TRISE;
+extern __sfr  __at (PIE1_ADDR)                    PIE1;
+extern __sfr  __at (PIE2_ADDR)                    PIE2;
+extern __sfr  __at (PCON_ADDR)                    PCON;
+extern __sfr  __at (SSPCON2_ADDR)                 SSPCON2;
+extern __sfr  __at (PR2_ADDR)                     PR2;
+extern __sfr  __at (SSPADD_ADDR)                  SSPADD;
+extern __sfr  __at (SSPSTAT_ADDR)                 SSPSTAT;
+extern __sfr  __at (TXSTA_ADDR)                   TXSTA;
+extern __sfr  __at (SPBRG_ADDR)                   SPBRG;
+extern __sfr  __at (ADRESL_ADDR)                  ADRESL;
+extern __sfr  __at (ADCON1_ADDR)                  ADCON1;
+
+extern __sfr  __at (EEDATA_ADDR)                  EEDATA;
+extern __sfr  __at (EEADR_ADDR)                   EEADR;
+extern __sfr  __at (EEDATH_ADDR)                  EEDATH;
+extern __sfr  __at (EEADRH_ADDR)                  EEADRH;
+
+extern __sfr  __at (EECON1_ADDR)                  EECON1;
+extern __sfr  __at (EECON2_ADDR)                  EECON2;
+
+//----- STATUS Bits --------------------------------------------------------
+
+
+//----- INTCON Bits --------------------------------------------------------
+
+
+//----- PIR1 Bits ----------------------------------------------------------
+
+
+//----- PIR2 Bits ----------------------------------------------------------
+
+
+//----- T1CON Bits ---------------------------------------------------------
+
+
+//----- T2CON Bits ---------------------------------------------------------
+
+
+//----- SSPCON Bits --------------------------------------------------------
+
+
+//----- CCP1CON Bits -------------------------------------------------------
+
+
+//----- RCSTA Bits ---------------------------------------------------------
+
+
+//----- CCP2CON Bits -------------------------------------------------------
+
+
+//----- ADCON0 Bits --------------------------------------------------------
+
+
+//----- OPTION_REG Bits -----------------------------------------------------
+
+
+//----- TRISE Bits ---------------------------------------------------------
+
+
+//----- PIE1 Bits ----------------------------------------------------------
+
+
+//----- PIE2 Bits ----------------------------------------------------------
+
+
+//----- PCON Bits ----------------------------------------------------------
+
+
+//----- SSPCON2 Bits --------------------------------------------------------
+
+
+//----- SSPSTAT Bits -------------------------------------------------------
+
+
+//----- TXSTA Bits ---------------------------------------------------------
+
+
+//----- ADCON1 Bits --------------------------------------------------------
+
+
+//----- EECON1 Bits --------------------------------------------------------
+
+
+//==========================================================================
+//
+//       RAM Definition
+//
+//==========================================================================
+
+//         __MAXRAM H'1FF'
+//         __BADRAM H'8F'-H'90', H'95'-H'97', H'9A'-H'9D'
+//         __BADRAM H'105', H'107'-H'109'
+//         __BADRAM H'185', H'187'-H'189', H'18E'-H'18F'
+
+//==========================================================================
+//
+//       Configuration Bits
+//
+//==========================================================================
+
+#define _CP_ALL              0x0FCF
+#define _CP_HALF             0x1FDF
+#define _CP_UPPER_256        0x2FEF
+#define _CP_OFF              0x3FFF
+#define _DEBUG_ON            0x37FF
+#define _DEBUG_OFF           0x3FFF
+#define _WRT_ENABLE_ON       0x3FFF
+#define _WRT_ENABLE_OFF      0x3DFF
+#define _CPD_ON              0x3EFF
+#define _CPD_OFF             0x3FFF
+#define _LVP_ON              0x3FFF
+#define _LVP_OFF             0x3F7F
+#define _BODEN_ON            0x3FFF
+#define _BODEN_OFF           0x3FBF
+#define _PWRTE_OFF           0x3FFF
+#define _PWRTE_ON            0x3FF7
+#define _WDT_ON              0x3FFF
+#define _WDT_OFF             0x3FFB
+#define _LP_OSC              0x3FFC
+#define _XT_OSC              0x3FFD
+#define _HS_OSC              0x3FFE
+#define _RC_OSC              0x3FFF
+
+//         LIST
+
+// ----- ADCON0 bits --------------------
 typedef union {
-       struct {
-               unsigned c      :1; /* Carry/borrow bit (ADDWF,ADDLW,SUBWF,SUBLW instructions) */
-               unsigned dc     :1; /* Digit carry/borrow bit (ADDWF,ADDLW,SUBWF,SUBLW instructions) */
-               unsigned z      :1; /* Zero bit */
-               unsigned not_pd :1; /* Power down bit */
-               unsigned not_to :1; /* Timeout bit */
-               unsigned rp0    :1; /* Register bank select bits for direct addressing */
-               unsigned rp1    :1;
-               unsigned irp    :1; /* Register bank select bits for indirect addressing */
-       };
-       unsigned char r;
-} status_t;
-
-static volatile status_t at status_addr status_b;
-#define C      status_b.c
-#define DC     status_b.dc
-#define Z      status_b.z
-#define NOT_PD status_b.not_pd
-#define NOT_TO status_b.not_to
-#define RP0    status_b.rp0
-#define RP1    status_b.rp1
-#define IRP    status_b.irp
-
-/* ---- OPTION_REG Bits ----------------------------------------------------- */
+  struct {
+    unsigned char ADON:1;
+    unsigned char :1;
+    unsigned char GO:1;
+    unsigned char CHS0:1;
+    unsigned char CHS1:1;
+    unsigned char CHS2:1;
+    unsigned char ADCS0:1;
+    unsigned char ADCS1:1;
+  };
+  struct {
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char NOT_DONE:1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+  };
+  struct {
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char GO_DONE:1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+  };
+} __ADCON0_bits_t;
+extern volatile __ADCON0_bits_t __at(ADCON0_ADDR) ADCON0_bits;
+
+#define ADON                 ADCON0_bits.ADON
+#define GO                   ADCON0_bits.GO
+#define NOT_DONE             ADCON0_bits.NOT_DONE
+#define GO_DONE              ADCON0_bits.GO_DONE
+#define CHS0                 ADCON0_bits.CHS0
+#define CHS1                 ADCON0_bits.CHS1
+#define CHS2                 ADCON0_bits.CHS2
+#define ADCS0                ADCON0_bits.ADCS0
+#define ADCS1                ADCON0_bits.ADCS1
+
+// ----- ADCON1 bits --------------------
 typedef union {
-       struct {
-               unsigned ps0      :1; /* Prescaler rate select bits */
-               unsigned ps1      :1;
-               unsigned ps2      :1;
-               unsigned psa      :1; /* Prescaler assignment bit */
-               unsigned t0se     :1; /* TMR0 source edge select bit */
-               unsigned t0cs     :1; /* TMR0 clock source select bit */
-               unsigned intedg   :1; /* Interrupt edge select bit */
-               unsigned not_rbpu :1; /* PortB pullup enable bit */
-       };
-       struct {
-               unsigned ps:3;
-       };
-       unsigned char r;
-} option_reg_t;
-
-static volatile option_reg_t at option_reg_addr option_reg_b;
-#define PS0      option_reg_b.ps0
-#define PS1      option_reg_b.ps1
-#define PS2      option_reg_b.ps2
-#define PSA      option_reg_b.psa
-#define T0SE     option_reg_b.t0se
-#define T0CS     option_reg_b.t0cs
-#define INTEDG   option_reg_b.intedg
-#define NOT_RBPU option_reg_b.not_rbpu
-
-/* ---- PCON Bits ---------------------------------------------------------- */
+  struct {
+    unsigned char PCFG0:1;
+    unsigned char PCFG1:1;
+    unsigned char PCFG2:1;
+    unsigned char PCFG3:1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char ADFM:1;
+  };
+} __ADCON1_bits_t;
+extern volatile __ADCON1_bits_t __at(ADCON1_ADDR) ADCON1_bits;
+
+#define PCFG0                ADCON1_bits.PCFG0
+#define PCFG1                ADCON1_bits.PCFG1
+#define PCFG2                ADCON1_bits.PCFG2
+#define PCFG3                ADCON1_bits.PCFG3
+#define ADFM                 ADCON1_bits.ADFM
+
+// ----- CCP1CON bits --------------------
 typedef union {
-       struct {
-               unsigned not_bor :1; /* Brown out reset status bit */
-               unsigned not_por :1; /* Power on reset bit */
-       };
-       unsigned char r;
-} pcon_t;
-
-static volatile pcon_t at pcon_addr pcon_b;
-#define NOT_BOR pcon_b.not_bor
-#define NOT_POR pcon_b.not_por
-
-/* ---- Misc Registers ----------------------------------------------------- */
-static volatile unsigned char at indf_addr indf;
-sfr at status_addr     status;
-sfr at pcl_addr        pcl;
-sfr at pclath_addr     pclath;
-sfr at fsr_addr        fsr;
-sfr at option_reg_addr option_reg;
-sfr at pcon_addr       pcon;
-sfr at pr2_addr        pr2;
-
-#define INDF       indf
-#define STATUS     status
-#define PCL        pcl
-#define PCLATH     pclath
-#define FSR        fsr
-#define OPTION_REG option_reg
-#define PCON       pcon
-#define INDF       indf
-#define PR2        pr2
-
-
-/*****************************************************************************
-       Ports
- *****************************************************************************/
-
-typedef struct {
-       unsigned b0 :1;
-       unsigned b1 :1;
-       unsigned b2 :1;
-       unsigned b3 :1;
-       unsigned b4 :1;
-       unsigned b5 :1;
-       unsigned b6 :1;
-       unsigned b7 :1;
-} bits_t;
-
+  struct {
+    unsigned char CCP1M0:1;
+    unsigned char CCP1M1:1;
+    unsigned char CCP1M2:1;
+    unsigned char CCP1M3:1;
+    unsigned char CCP1Y:1;
+    unsigned char CCP1X:1;
+    unsigned char :1;
+    unsigned char :1;
+  };
+} __CCP1CON_bits_t;
+extern volatile __CCP1CON_bits_t __at(CCP1CON_ADDR) CCP1CON_bits;
+
+#define CCP1M0               CCP1CON_bits.CCP1M0
+#define CCP1M1               CCP1CON_bits.CCP1M1
+#define CCP1M2               CCP1CON_bits.CCP1M2
+#define CCP1M3               CCP1CON_bits.CCP1M3
+#define CCP1Y                CCP1CON_bits.CCP1Y
+#define CCP1X                CCP1CON_bits.CCP1X
+
+// ----- CCP2CON bits --------------------
 typedef union {
-       bits_t;
-       unsigned char r;
-} port_t;
-
+  struct {
+    unsigned char CCP2M0:1;
+    unsigned char CCP2M1:1;
+    unsigned char CCP2M2:1;
+    unsigned char CCP2M3:1;
+    unsigned char CCP2Y:1;
+    unsigned char CCP2X:1;
+    unsigned char :1;
+    unsigned char :1;
+  };
+} __CCP2CON_bits_t;
+extern volatile __CCP2CON_bits_t __at(CCP2CON_ADDR) CCP2CON_bits;
+
+#define CCP2M0               CCP2CON_bits.CCP2M0
+#define CCP2M1               CCP2CON_bits.CCP2M1
+#define CCP2M2               CCP2CON_bits.CCP2M2
+#define CCP2M3               CCP2CON_bits.CCP2M3
+#define CCP2Y                CCP2CON_bits.CCP2Y
+#define CCP2X                CCP2CON_bits.CCP2X
+
+// ----- EECON1 bits --------------------
+typedef union {
+  struct {
+    unsigned char RD:1;
+    unsigned char WR:1;
+    unsigned char WREN:1;
+    unsigned char WRERR:1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char EEPGD:1;
+  };
+} __EECON1_bits_t;
+extern volatile __EECON1_bits_t __at(EECON1_ADDR) EECON1_bits;
+
+#define RD                   EECON1_bits.RD
+#define WR                   EECON1_bits.WR
+#define WREN                 EECON1_bits.WREN
+#define WRERR                EECON1_bits.WRERR
+#define EEPGD                EECON1_bits.EEPGD
+
+// ----- INTCON bits --------------------
+typedef union {
+  struct {
+    unsigned char RBIF:1;
+    unsigned char INTF:1;
+    unsigned char T0IF:1;
+    unsigned char RBIE:1;
+    unsigned char INTE:1;
+    unsigned char T0IE:1;
+    unsigned char PEIE:1;
+    unsigned char GIE:1;
+  };
+} __INTCON_bits_t;
+extern volatile __INTCON_bits_t __at(INTCON_ADDR) INTCON_bits;
+
+#define RBIF                 INTCON_bits.RBIF
+#define INTF                 INTCON_bits.INTF
+#define T0IF                 INTCON_bits.T0IF
+#define RBIE                 INTCON_bits.RBIE
+#define INTE                 INTCON_bits.INTE
+#define T0IE                 INTCON_bits.T0IE
+#define PEIE                 INTCON_bits.PEIE
+#define GIE                  INTCON_bits.GIE
+
+// ----- OPTION_REG bits --------------------
+typedef union {
+  struct {
+    unsigned char PS0:1;
+    unsigned char PS1:1;
+    unsigned char PS2:1;
+    unsigned char PSA:1;
+    unsigned char T0SE:1;
+    unsigned char T0CS:1;
+    unsigned char INTEDG:1;
+    unsigned char NOT_RBPU:1;
+  };
+} __OPTION_REG_bits_t;
+extern volatile __OPTION_REG_bits_t __at(OPTION_REG_ADDR) OPTION_REG_bits;
+
+#define PS0                  OPTION_REG_bits.PS0
+#define PS1                  OPTION_REG_bits.PS1
+#define PS2                  OPTION_REG_bits.PS2
+#define PSA                  OPTION_REG_bits.PSA
+#define T0SE                 OPTION_REG_bits.T0SE
+#define T0CS                 OPTION_REG_bits.T0CS
+#define INTEDG               OPTION_REG_bits.INTEDG
+#define NOT_RBPU             OPTION_REG_bits.NOT_RBPU
+
+// ----- PCON bits --------------------
+typedef union {
+  struct {
+    unsigned char NOT_BO:1;
+    unsigned char NOT_POR:1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+  };
+  struct {
+    unsigned char NOT_BOR:1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+  };
+} __PCON_bits_t;
+extern volatile __PCON_bits_t __at(PCON_ADDR) PCON_bits;
+
+#define NOT_BO               PCON_bits.NOT_BO
+#define NOT_BOR              PCON_bits.NOT_BOR
+#define NOT_POR              PCON_bits.NOT_POR
+
+// ----- PIE1 bits --------------------
+typedef union {
+  struct {
+    unsigned char TMR1IE:1;
+    unsigned char TMR2IE:1;
+    unsigned char CCP1IE:1;
+    unsigned char SSPIE:1;
+    unsigned char TXIE:1;
+    unsigned char RCIE:1;
+    unsigned char ADIE:1;
+    unsigned char PSPIE:1;
+  };
+} __PIE1_bits_t;
+extern volatile __PIE1_bits_t __at(PIE1_ADDR) PIE1_bits;
+
+#define TMR1IE               PIE1_bits.TMR1IE
+#define TMR2IE               PIE1_bits.TMR2IE
+#define CCP1IE               PIE1_bits.CCP1IE
+#define SSPIE                PIE1_bits.SSPIE
+#define TXIE                 PIE1_bits.TXIE
+#define RCIE                 PIE1_bits.RCIE
+#define ADIE                 PIE1_bits.ADIE
+#define PSPIE                PIE1_bits.PSPIE
+
+// ----- PIE2 bits --------------------
+typedef union {
+  struct {
+    unsigned char CCP2IE:1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char BCLIE:1;
+    unsigned char EEIE:1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+  };
+} __PIE2_bits_t;
+extern volatile __PIE2_bits_t __at(PIE2_ADDR) PIE2_bits;
+
+#define CCP2IE               PIE2_bits.CCP2IE
+#define BCLIE                PIE2_bits.BCLIE
+#define EEIE                 PIE2_bits.EEIE
+
+// ----- PIR1 bits --------------------
+typedef union {
+  struct {
+    unsigned char TMR1IF:1;
+    unsigned char TMR2IF:1;
+    unsigned char CCP1IF:1;
+    unsigned char SSPIF:1;
+    unsigned char TXIF:1;
+    unsigned char RCIF:1;
+    unsigned char ADIF:1;
+    unsigned char PSPIF:1;
+  };
+} __PIR1_bits_t;
+extern volatile __PIR1_bits_t __at(PIR1_ADDR) PIR1_bits;
+
+#define TMR1IF               PIR1_bits.TMR1IF
+#define TMR2IF               PIR1_bits.TMR2IF
+#define CCP1IF               PIR1_bits.CCP1IF
+#define SSPIF                PIR1_bits.SSPIF
+#define TXIF                 PIR1_bits.TXIF
+#define RCIF                 PIR1_bits.RCIF
+#define ADIF                 PIR1_bits.ADIF
+#define PSPIF                PIR1_bits.PSPIF
+
+// ----- PIR2 bits --------------------
+typedef union {
+  struct {
+    unsigned char CCP2IF:1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char BCLIF:1;
+    unsigned char EEIF:1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+  };
+} __PIR2_bits_t;
+extern volatile __PIR2_bits_t __at(PIR2_ADDR) PIR2_bits;
+
+#define CCP2IF               PIR2_bits.CCP2IF
+#define BCLIF                PIR2_bits.BCLIF
+#define EEIF                 PIR2_bits.EEIF
+
+// ----- PORTA bits --------------------
 typedef union {
-       bits_t;
-       unsigned char r;
-} tris_t;
-
-/* --- PORTA Bits ---------------------------------------------------------- */
-static volatile port_t at porta_addr porta_b;
-#define PA0 porta_b.b0
-#define PA1 porta_b.b1
-#define PA2 porta_b.b2
-#define PA3 porta_b.b3
-#define PA4 porta_b.b4
-#define PA5 porta_b.b5
-#define PA6 porta_b.b6
-#define PA7 porta_b.b7
-
-/* --- PORTB Bits ---------------------------------------------------------- */
-static volatile port_t at portb_addr portb_b;
-#define PB0 portb_b.b0
-#define PB1 portb_b.b1
-#define PB2 portb_b.b2
-#define PB3 portb_b.b3
-#define PB4 portb_b.b4
-#define PB5 portb_b.b5
-#define PB6 portb_b.b6
-#define PB7 portb_b.b7
-
-/* --- PORTC Bits ---------------------------------------------------------- */
-static volatile port_t at portc_addr portc_b;
-#define PC0 portc_b.b0
-#define PC1 portc_b.b1
-#define PC2 portc_b.b2
-#define PC3 portc_b.b3
-#define PC4 portc_b.b4
-#define PC5 portc_b.b5
-#define PC6 portc_b.b6
-#define PC7 portc_b.b7
-
-/* --- PORTD Bits ---------------------------------------------------------- */
-static volatile port_t at portd_addr portd_b;
-#define PD0 portd_b.b0
-#define PD1 portd_b.b1
-#define PD2 portd_b.b2
-#define PD3 portd_b.b3
-#define PD4 portd_b.b4
-#define PD5 portd_b.b5
-#define PD6 portd_b.b6
-#define PD7 portd_b.b7
-
-/* --- PORTE Bits ---------------------------------------------------------- */
-static volatile port_t at porte_addr porte_b;
-#define RE0 porte_b.b0
-#define RE1 porte_b.b1
-#define RE2 porte_b.b2
-
-/* --- TRISA Bits ---------------------------------------------------------- */
-static volatile tris_t at trisa_addr trisa_b;
-#define TRISA0 trisa_b.b0
-#define TRISA1 trisa_b.b1
-#define TRISA2 trisa_b.b2
-#define TRISA3 trisa_b.b3
-#define TRISA4 trisa_b.b4
-#define TRISA5 trisa_b.b5
-#define TRISA6 trisa_b.b6
-#define TRISA7 trisa_b.b7
-
-/* --- TRISB Bits ---------------------------------------------------------- */
-static  tris_t at trisb_addr trisb_b;
-#define TRISB0 trisb_b.b0
-#define TRISB1 trisb_b.b1
-#define TRISB2 trisb_b.b2
-#define TRISB3 trisb_b.b3
-#define TRISB4 trisb_b.b4
-#define TRISB5 trisb_b.b5
-#define TRISB6 trisb_b.b6
-#define TRISB7 trisb_b.b7
-
-/* --- TRISC Bits ---------------------------------------------------------- */
-static volatile tris_t at trisc_addr trisc_b;
-#define TRISC0 trisc_b.b0
-#define TRISC1 trisc_b.b1
-#define TRISC2 trisc_b.b2
-#define TRISC3 trisc_b.b3
-#define TRISC4 trisc_b.b4
-#define TRISC5 trisc_b.b5
-#define TRISC6 trisc_b.b6
-#define TRISC7 trisc_b.b7
-
-/* --- TRISD Bits ---------------------------------------------------------- */
-static volatile tris_t at trisd_addr trisd_b;
-#define TRISD0 trisd_b.b0
-#define TRISD1 trisd_b.b1
-#define TRISD2 trisd_b.b2
-#define TRISD3 trisd_b.b3
-#define TRISD4 trisd_b.b4
-#define TRISD5 trisd_b.b5
-#define TRISD6 trisd_b.b6
-#define TRISD7 trisd_b.b7
-
-/* --- TRISE Bits ---------------------------------------------------------- */
+  struct {
+    unsigned char RA0:1;
+    unsigned char RA1:1;
+    unsigned char RA2:1;
+    unsigned char RA3:1;
+    unsigned char RA4:1;
+    unsigned char RA5:1;
+    unsigned char :1;
+    unsigned char :1;
+  };
+} __PORTA_bits_t;
+extern volatile __PORTA_bits_t __at(PORTA_ADDR) PORTA_bits;
+
+#define RA0                  PORTA_bits.RA0
+#define RA1                  PORTA_bits.RA1
+#define RA2                  PORTA_bits.RA2
+#define RA3                  PORTA_bits.RA3
+#define RA4                  PORTA_bits.RA4
+#define RA5                  PORTA_bits.RA5
+
+// ----- PORTB bits --------------------
 typedef union {
-       struct {
-               unsigned bit0    :1; /* Data direction bits */
-               unsigned bit1    :1;
-               unsigned bit2    :1;
-               unsigned         :1;
-               unsigned pspmode :1; /* Parrallel slave port mode select bit */
-               unsigned ibov    :1; /* Input buffer overflow detect bit */
-               unsigned obf     :1; /* Output buffer full status bit */
-               unsigned ibf     :1; /* Input buffer full status bit */
-       };
-       struct {
-               unsigned trise:3;
-       };
-       bits_t;
-       unsigned char r;
-} trise_t;
-
-static volatile trise_t at trise_addr  trise_b;
-#define TRISE0  trise_b.bit0
-#define TRISE1  trise_b.bit1
-#define TRISE2  trise_b.bit2
-#define PSPMODE trise_b.pspmode
-#define IBOV    trise_b.ibov
-#define OBF     trise_b.obf
-#define IBF     trise_b.ibf
-
-/* ---- Port Registers ----------------------------------------------------- */
-sfr at porta_addr porta;
-sfr at portb_addr portb;
-sfr at portc_addr portc;
-sfr at portd_addr portd;
-sfr at porte_addr porte;
-sfr at trisa_addr trisa;
-sfr at trisb_addr trisb;
-sfr at trisc_addr trisc;
-sfr at trisd_addr trisd;
-sfr at trise_addr trise;
-#define PORTA porta
-#define PORTB portb
-#define PORTC portc
-#define PORTD portd
-#define PORTE porte
-#define TRISA trisa
-#define TRISB trisb
-#define TRISC trisc
-#define TRISD trisd
-#define TRISE trise
-
-
-/*****************************************************************************
-       Interrupts
- *****************************************************************************/
-
-/* ---- INTCON Bits -------------------------------------------------------- */
+  struct {
+    unsigned char RB0:1;
+    unsigned char RB1:1;
+    unsigned char RB2:1;
+    unsigned char RB3:1;
+    unsigned char RB4:1;
+    unsigned char RB5:1;
+    unsigned char RB6:1;
+    unsigned char RB7:1;
+  };
+} __PORTB_bits_t;
+extern volatile __PORTB_bits_t __at(PORTB_ADDR) PORTB_bits;
+
+#define RB0                  PORTB_bits.RB0
+#define RB1                  PORTB_bits.RB1
+#define RB2                  PORTB_bits.RB2
+#define RB3                  PORTB_bits.RB3
+#define RB4                  PORTB_bits.RB4
+#define RB5                  PORTB_bits.RB5
+#define RB6                  PORTB_bits.RB6
+#define RB7                  PORTB_bits.RB7
+
+// ----- PORTC bits --------------------
 typedef union {
-       struct {
-               unsigned rbif   :1; /* RB port change interrupt flag bit */
-               unsigned ntf    :1; /* RB0/INT external interrupt flag bit */
-               unsigned tmr0if :1; /* TMR0 overflow interrupt flag bit */
-               unsigned rbie   :1; /* RB port change interrupt enable bit */
-               unsigned inte   :1; /* RB0/INT external interrupt enable */
-               unsigned tmr0ie :1; /* TMR0 over flow interrupt enble bit */
-               unsigned peie   :1; /* Peripheral interrupt enable bit */
-               unsigned gie    :1; /* Global interrupt enable bit */
-       };
-       unsigned char r;
-} intcon_t;
-
-static volatile intcon_t at intcon_addr intcon_b;
-#define RBIF intcon_b.rbif
-#define NTF  intcon_b.ntf
-#define T0IF intcon_b.tmr0if
-#define RBIE intcon_b.rbie
-#define INTE intcon_b.inte
-#define T0IE intcon_b.tmr0ie
-#define PEIE intcon_b.peie
-#define GIE  intcon_b.gie
-
-/* ---- PIR1 Bits ---------------------------------------------------------- */
+  struct {
+    unsigned char RC0:1;
+    unsigned char RC1:1;
+    unsigned char RC2:1;
+    unsigned char RC3:1;
+    unsigned char RC4:1;
+    unsigned char RC5:1;
+    unsigned char RC6:1;
+    unsigned char RC7:1;
+  };
+} __PORTC_bits_t;
+extern volatile __PORTC_bits_t __at(PORTC_ADDR) PORTC_bits;
+
+#define RC0                  PORTC_bits.RC0
+#define RC1                  PORTC_bits.RC1
+#define RC2                  PORTC_bits.RC2
+#define RC3                  PORTC_bits.RC3
+#define RC4                  PORTC_bits.RC4
+#define RC5                  PORTC_bits.RC5
+#define RC6                  PORTC_bits.RC6
+#define RC7                  PORTC_bits.RC7
+
+// ----- PORTD bits --------------------
 typedef union {
-       struct {
-               unsigned tmr1if :1; /* Tmr1 overflow interrupt flag bit */
-               unsigned tmr2if :1; /* TMR2 to PR2 match interrupt flag bit */
-               unsigned ccp1if :1; /* CCP1 interrupt flag bit */
-               unsigned sspif  :1; /* Synchronous serial port interrupt flag bit */
-               unsigned txif   :1; /* USART transmit interrupt flag bit */
-               unsigned rcif   :1; /* USART receiver interrupt flag bit */
-               unsigned adif   :1; /* A/D converter interrupt flag bit */
-               unsigned pspif  :1; /* Parrallel slave port read/write interrupt flag bit */
-       };
-       unsigned char r;
-} pir1_t;
-
-static volatile pir1_t at pir1_addr pir1_b;
-#define TMR1IF pir1_b.tmr1if
-#define TMR2IF pir1_b.tmr2if
-#define CCP1IF pir1_b.ccp1if
-#define SSPIF  pir1_b.sspif
-#define TXIF   pir1_b.txif
-#define RCIF   pir1_b.rcif
-#define ADIF   pir1_b.adif
-#define PSPIF  pir1_b.pspif
-
-/* ---- PIR2 Bits ---------------------------------------------------------- */
+  struct {
+    unsigned char RD0:1;
+    unsigned char RD1:1;
+    unsigned char RD2:1;
+    unsigned char RD3:1;
+    unsigned char RD4:1;
+    unsigned char RD5:1;
+    unsigned char RD6:1;
+    unsigned char RD7:1;
+  };
+} __PORTD_bits_t;
+extern volatile __PORTD_bits_t __at(PORTD_ADDR) PORTD_bits;
+
+#define RD0                  PORTD_bits.RD0
+#define RD1                  PORTD_bits.RD1
+#define RD2                  PORTD_bits.RD2
+#define RD3                  PORTD_bits.RD3
+#define RD4                  PORTD_bits.RD4
+#define RD5                  PORTD_bits.RD5
+#define RD6                  PORTD_bits.RD6
+#define RD7                  PORTD_bits.RD7
+
+// ----- PORTE bits --------------------
 typedef union {
-       struct {
-               unsigned ccp2if :1; /* CCP2 interrupt enable bit */
-               unsigned        :1;
-               unsigned        :1;
-               unsigned bclif  :1; /* Bus collision interrupt enable bit */
-               unsigned eeif   :1; /* EEPROM write operation interrupt enable bit */
-               unsigned        :1;
-               unsigned cmif   :1; /* Comparitor interrupt flag bit */
-       };
-       unsigned char r;
-} pir2_t;
-
-static volatile pir2_t at pir2_addr pir2_b;
-#define CCP2IF pir2_b.ccp2if
-#define BCLIF  pir2_b.bclif
-#define EEIF   pir2_b.eeif
-
-/* ---- PIE1 Bits ---------------------------------------------------------- */
+  struct {
+    unsigned char RE0:1;
+    unsigned char RE1:1;
+    unsigned char RE2:1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+  };
+} __PORTE_bits_t;
+extern volatile __PORTE_bits_t __at(PORTE_ADDR) PORTE_bits;
+
+#define RE0                  PORTE_bits.RE0
+#define RE1                  PORTE_bits.RE1
+#define RE2                  PORTE_bits.RE2
+
+// ----- RCSTA bits --------------------
 typedef union {
-       struct {
-               unsigned tmr1ie :1; /* Tmr1 overflow interrupt enable bit */
-               unsigned tmr2ie :1; /* TMR2 to PR2 match interrupt enable bit */
-               unsigned ccp1ie :1; /* CCP1 interrupt enable bit */
-               unsigned sspie  :1; /* Synchronous serial port interrupt enable bit */
-               unsigned txie   :1; /* USART transmit interrupt enable bit */
-               unsigned rcie   :1; /* USART receiver interrupt enable bit */
-               unsigned adie   :1; /* A/D converter interrupt enable bit */
-               unsigned pspie  :1; /* Parrallel slave port read/write interrupt enable bit */
-       };
-       unsigned char r;
-} pie1_t;
-
-static volatile pie1_t at pie1_addr pie1_b;
-#define TMR1IE pie1_b.tmr1ie
-#define TMR2IE pie1_b.tmr2ie
-#define CCP1IE pie1_b.ccp1ie
-#define SSPIE  pie1_b.sspie
-#define TXIE   pie1_b.txie
-#define RCIE   pie1_b.rcie
-#define ADIE   pie1_b.adie
-#define PSPIE  pie1_b.pspie
-
-/* ---- PIE2 Bits ---------------------------------------------------------- */
+  struct {
+    unsigned char RX9D:1;
+    unsigned char OERR:1;
+    unsigned char FERR:1;
+    unsigned char ADDEN:1;
+    unsigned char CREN:1;
+    unsigned char SREN:1;
+    unsigned char RX9:1;
+    unsigned char SPEN:1;
+  };
+  struct {
+    unsigned char RCD8:1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char RC9:1;
+    unsigned char :1;
+  };
+  struct {
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char NOT_RC8:1;
+    unsigned char :1;
+  };
+  struct {
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char RC8_9:1;
+    unsigned char :1;
+  };
+} __RCSTA_bits_t;
+extern volatile __RCSTA_bits_t __at(RCSTA_ADDR) RCSTA_bits;
+
+#define RX9D                 RCSTA_bits.RX9D
+#define RCD8                 RCSTA_bits.RCD8
+#define OERR                 RCSTA_bits.OERR
+#define FERR                 RCSTA_bits.FERR
+#define ADDEN                RCSTA_bits.ADDEN
+#define CREN                 RCSTA_bits.CREN
+#define SREN                 RCSTA_bits.SREN
+#define RX9                  RCSTA_bits.RX9
+#define RC9                  RCSTA_bits.RC9
+#define NOT_RC8              RCSTA_bits.NOT_RC8
+#define RC8_9                RCSTA_bits.RC8_9
+#define SPEN                 RCSTA_bits.SPEN
+
+// ----- SSPCON bits --------------------
 typedef union {
-       struct {
-               unsigned ccp2ie :1; /* CCP2 interrupt enable bit */
-               unsigned        :1;
-               unsigned        :1;
-               unsigned bclie  :1; /* Bus collision interrupt enable bit */
-               unsigned eeie   :1; /* EEPROM write operation interrupt enable bit */
-               unsigned        :1;
-               unsigned cmie   :1; /* Comparitor interrupt enable bit */
-       };
-       unsigned char r;
-} pie2_t;
-
-static volatile pie2_t at pie2_addr pie2_b;
-#define CCP2IE pie2_b.ccp2ie
-#define BCLIE  pie2_b.bclie
-#define EEIE   pie2_b.eeie
-#define CMIE   pie2_b.cmie
-
-/* ---- Interrupt Registers ------------------------------------------------ */
-sfr at intcon_addr intcon;
-sfr at pir1_addr   pir1;
-sfr at pir2_addr   pir2;
-sfr at pie1_addr   pie1;
-sfr at pie2_addr   pie2;
-
-#define INTCON intcon
-#define PIR1   pir1
-#define PIR2   pir2
-#define PIE1   pie1
-#define PIE2   pie2
-
-/*****************************************************************************
-       Timers
- *****************************************************************************/
-
-/* ---- T1CON Bits --------------------------------------------------------- */
+  struct {
+    unsigned char SSPM0:1;
+    unsigned char SSPM1:1;
+    unsigned char SSPM2:1;
+    unsigned char SSPM3:1;
+    unsigned char CKP:1;
+    unsigned char SSPEN:1;
+    unsigned char SSPOV:1;
+    unsigned char WCOL:1;
+  };
+} __SSPCON_bits_t;
+extern volatile __SSPCON_bits_t __at(SSPCON_ADDR) SSPCON_bits;
+
+#define SSPM0                SSPCON_bits.SSPM0
+#define SSPM1                SSPCON_bits.SSPM1
+#define SSPM2                SSPCON_bits.SSPM2
+#define SSPM3                SSPCON_bits.SSPM3
+#define CKP                  SSPCON_bits.CKP
+#define SSPEN                SSPCON_bits.SSPEN
+#define SSPOV                SSPCON_bits.SSPOV
+#define WCOL                 SSPCON_bits.WCOL
+
+// ----- SSPCON2 bits --------------------
 typedef union {
-       struct {
-               unsigned tmr1on  :1; /* Timer1 on bit */
-               unsigned tmr1cs  :1; /* Timer1 clock source select bit */
-               unsigned t1sync  :1; /* Timer1 external clock input synchronization control bit */
-               unsigned t1oscen :1; /* Timer1 oscilator enable control bit */
-               unsigned t1ckps0 :1; /* Timer1 input clock prescale select bits */
-               unsigned t1ckps1 :1;
-       };
-       struct {
-               unsigned        :1;
-               unsigned        :1;
-               unsigned        :1;
-               unsigned        :1;
-               unsigned t1ckps :2; /* Timer1 input clock prescale select bits */
-       };
-       bits_t;
-       unsigned char r;
-} t1con_t;
-
-static volatile t1con_t at t1con_addr t1con_b;
-#define TMR1ON     t1con_b.tmr1on
-#define TMR1CS     t1con_b.tmr1cs
-#define T1SYNC     t1con_b.t1sync
-#define NOT_T1SYNC t1con_b.t1sync
-#define T1OSCEN    t1con_b.t1oscen
-#define T1CKPS0    t1con_b.t1ckps0
-#define T1CKPS1    t1con_b.t1ckps1
-
-/* ---- T2CON Bits --------------------------------------------------------- */
+  struct {
+    unsigned char SEN:1;
+    unsigned char RSEN:1;
+    unsigned char PEN:1;
+    unsigned char RCEN:1;
+    unsigned char ACKEN:1;
+    unsigned char ACKDT:1;
+    unsigned char ACKSTAT:1;
+    unsigned char GCEN:1;
+  };
+} __SSPCON2_bits_t;
+extern volatile __SSPCON2_bits_t __at(SSPCON2_ADDR) SSPCON2_bits;
+
+#define SEN                  SSPCON2_bits.SEN
+#define RSEN                 SSPCON2_bits.RSEN
+#define PEN                  SSPCON2_bits.PEN
+#define RCEN                 SSPCON2_bits.RCEN
+#define ACKEN                SSPCON2_bits.ACKEN
+#define ACKDT                SSPCON2_bits.ACKDT
+#define ACKSTAT              SSPCON2_bits.ACKSTAT
+#define GCEN                 SSPCON2_bits.GCEN
+
+// ----- SSPSTAT bits --------------------
 typedef union {
-       struct {
-               unsigned t2ckps0 :1; /* Timer2 clock prescale select bits */
-               unsigned t2ckps1 :1;
-               unsigned tmr2on  :1; /* Timer2 on bit */
-               unsigned toutps0 :1;
-               unsigned toutps1 :1; /* Timer2 output postscale selet bits */
-               unsigned toutps2 :1;
-               unsigned toutps3 :1;
-       };
-       struct {
-               unsigned t2ckps :2; /* Timer2 clock prescale select bits */
-               unsigned        :1;
-               unsigned toutps :4; /* Timer2 output postscale selet bits */
-       };
-       unsigned char r;
-} t2con_t;
-
-static volatile t2con_t at t2con_addr t2con_b;
-#define T2CKPS0 t2con_b.t2ckps0
-#define T2CKPS1 t2con_b.t2ckps1
-#define TMR2ON  t2con_b.tmr2on
-#define TOUTPS0 t2con_b.toutps0
-#define TOUTPS1 t2con_b.toutps1
-#define TOUTPS2 t2con_b.toutps2
-#define TOUTPS3 t2con_b.toutps3
-
-/* ---- Timer Registers ---------------------------------------------------- */
-sfr at tmr0_addr   tmr0;
-sfr at tmr1l_addr  tmr1l;
-sfr at tmr1h_addr  tmr1h;
-sfr at tmr2_addr   tmr2;
-sfr at t1con_addr  t1con;
-sfr at t2con_addr  t2con;
-
-#define TMR0  tmr0
-#define TMR1L tmr1l
-#define TMR1H tmr1h
-#define TMR2  tmr2
-#define T1CON t1con
-#define T2CON t2con
-
-
-/*****************************************************************************
-       Comparitors
- *****************************************************************************/
-
-/* ----- CCPCON Bits -------------------------------------------------------- */
+  struct {
+    unsigned char BF:1;
+    unsigned char UA:1;
+    unsigned char R:1;
+    unsigned char S:1;
+    unsigned char P:1;
+    unsigned char D:1;
+    unsigned char CKE:1;
+    unsigned char SMP:1;
+  };
+  struct {
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char I2C_READ:1;
+    unsigned char I2C_START:1;
+    unsigned char I2C_STOP:1;
+    unsigned char I2C_DATA:1;
+    unsigned char :1;
+    unsigned char :1;
+  };
+  struct {
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char NOT_W:1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char NOT_A:1;
+    unsigned char :1;
+    unsigned char :1;
+  };
+  struct {
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char NOT_WRITE:1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char NOT_ADDRESS:1;
+    unsigned char :1;
+    unsigned char :1;
+  };
+  struct {
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char R_W:1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char D_A:1;
+    unsigned char :1;
+    unsigned char :1;
+  };
+  struct {
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char READ_WRITE:1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char DATA_ADDRESS:1;
+    unsigned char :1;
+    unsigned char :1;
+  };
+} __SSPSTAT_bits_t;
+extern volatile __SSPSTAT_bits_t __at(SSPSTAT_ADDR) SSPSTAT_bits;
+
+#define BF                   SSPSTAT_bits.BF
+#define UA                   SSPSTAT_bits.UA
+#define R                    SSPSTAT_bits.R
+#define I2C_READ             SSPSTAT_bits.I2C_READ
+#define NOT_W                SSPSTAT_bits.NOT_W
+#define NOT_WRITE            SSPSTAT_bits.NOT_WRITE
+#define R_W                  SSPSTAT_bits.R_W
+#define READ_WRITE           SSPSTAT_bits.READ_WRITE
+#define S                    SSPSTAT_bits.S
+#define I2C_START            SSPSTAT_bits.I2C_START
+#define P                    SSPSTAT_bits.P
+#define I2C_STOP             SSPSTAT_bits.I2C_STOP
+#define D                    SSPSTAT_bits.D
+#define I2C_DATA             SSPSTAT_bits.I2C_DATA
+#define NOT_A                SSPSTAT_bits.NOT_A
+#define NOT_ADDRESS          SSPSTAT_bits.NOT_ADDRESS
+#define D_A                  SSPSTAT_bits.D_A
+#define DATA_ADDRESS         SSPSTAT_bits.DATA_ADDRESS
+#define CKE                  SSPSTAT_bits.CKE
+#define SMP                  SSPSTAT_bits.SMP
+
+// ----- STATUS bits --------------------
 typedef union {
-       struct {
-               unsigned ccpm0 :1; /* CCPx mode select bits */
-               unsigned ccpm1 :1;
-               unsigned ccpm2 :1;
-               unsigned ccpm3 :1;
-               unsigned ccpy  :1; /* PWM least significant bits */
-               unsigned ccpx  :1;
-       };
-       struct {
-               unsigned ccpm :4; /* CCPx mode select bits */
-       };
-       unsigned char r;
-} ccpcon_t;
-
-static volatile ccpcon_t at ccp1con_addr ccp1con_b;
-#define CCP1M0 ccp1con_b.ccpm0
-#define CCP1M1 ccp1con_b.ccpm1
-#define CCP1M2 ccp1con_b.ccpm2
-#define CCP1M3 ccp1con_b.ccpm3
-#define CCP1Y  ccp1con_b.ccpy
-#define CCP1X  ccp1con_b.ccpx
-
-static volatile ccpcon_t at ccp2con_addr ccp2con_b;
-#define CCP2M0 ccp2con_b.ccpm0
-#define CCP2M1 ccp2con_b.ccpm1
-#define CCP2M2 ccp2con_b.ccpm2
-#define CCP2M3 ccp2con_b.ccpm3
-#define CCP2Y  ccp2con_b.ccpy
-#define CCP2X  ccp2con_b.ccpx
-
-/* ---- Timer Registers ---------------------------------------------------- */
-sfr at ccpr1l_addr   CCPR1L;
-sfr at ccpr1h_addr   CCPR1H;
-sfr at ccp1con_addr  CCP1CON;
-sfr at ccpr2l_addr   CCPR2L;
-sfr at ccpr2h_addr   CCPR2H;
-sfr at ccp2con_addr  CCP2CON;
-
-
-/*****************************************************************************
-       SSP
- *****************************************************************************/
-
-/* ---- SSPCON Bits -------------------------------------------------------- */
+  struct {
+    unsigned char C:1;
+    unsigned char DC:1;
+    unsigned char Z:1;
+    unsigned char NOT_PD:1;
+    unsigned char NOT_TO:1;
+    unsigned char RP0:1;
+    unsigned char RP1:1;
+    unsigned char IRP:1;
+  };
+} __STATUS_bits_t;
+extern volatile __STATUS_bits_t __at(STATUS_ADDR) STATUS_bits;
+
+#define C                    STATUS_bits.C
+#define DC                   STATUS_bits.DC
+#define Z                    STATUS_bits.Z
+#define NOT_PD               STATUS_bits.NOT_PD
+#define NOT_TO               STATUS_bits.NOT_TO
+#define RP0                  STATUS_bits.RP0
+#define RP1                  STATUS_bits.RP1
+#define IRP                  STATUS_bits.IRP
+
+// ----- T1CON bits --------------------
 typedef union {
-       struct {
-               unsigned sspm0 :1; /* Synchronous serial port mode select bits */
-               unsigned sspm1 :1;
-               unsigned sspm2 :1;
-               unsigned sspm3 :1;
-               unsigned ckp   :1; /* Clock polarity select bits */
-               unsigned sspen :1; /* Synchronous serial port enable bits */
-               unsigned sspov :1; /* Receive overflow indicator bit */
-               unsigned wcol  :1; /* Write collision dedect bit */
-       };
-       struct {
-               unsigned sspm :4; /* Synchronous serial port mode select bits */
-       };
-       unsigned char r;
-} sspcon_t;
-
-static volatile sspcon_t at sspcon_addr sspcon_b;
-#define SSPM0 sspcon_b.sspm0
-#define SSPM1 sspcon_b.sspm1
-#define SSPM2 sspcon_b.sspm2
-#define SSPM3 sspcon_b.sspm3
-#define CKP   sspcon_b.ckp
-#define SSPEN sspcon_b.sspen
-#define SSPOV sspcon_b.sspov
-#define WCOL  sspcon_b.wcol
-
-/* ---- SSPCON2 Bits -------------------------------------------------------- */
+  struct {
+    unsigned char TMR1ON:1;
+    unsigned char TMR1CS:1;
+    unsigned char NOT_T1SYNC:1;
+    unsigned char T1OSCEN:1;
+    unsigned char T1CKPS0:1;
+    unsigned char T1CKPS1:1;
+    unsigned char :1;
+    unsigned char :1;
+  };
+  struct {
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char T1INSYNC:1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+  };
+  struct {
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char T1SYNC:1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+  };
+} __T1CON_bits_t;
+extern volatile __T1CON_bits_t __at(T1CON_ADDR) T1CON_bits;
+
+#define TMR1ON               T1CON_bits.TMR1ON
+#define TMR1CS               T1CON_bits.TMR1CS
+#define NOT_T1SYNC           T1CON_bits.NOT_T1SYNC
+#define T1INSYNC             T1CON_bits.T1INSYNC
+#define T1SYNC               T1CON_bits.T1SYNC
+#define T1OSCEN              T1CON_bits.T1OSCEN
+#define T1CKPS0              T1CON_bits.T1CKPS0
+#define T1CKPS1              T1CON_bits.T1CKPS1
+
+// ----- T2CON bits --------------------
 typedef union {
-       struct {
-               unsigned sen     :1; /* START condition enabled/stretch enabled bit */
-               unsigned rsen    :1; /* Repeated START condition enabled bit */
-               unsigned pen     :1; /* STOP condition enable bit */
-               unsigned rcen    :1; /* Receive enable bit */
-               unsigned acken   :1; /* Acknowledge sequence enable bit */
-               unsigned ackdt   :1; /* Acknowledge data bit (master receive mode only) */
-               unsigned ackstat :1; /* Acknowledge status bit (master transmit mode only) */
-               unsigned gcen    :1; /* General call enable bit */
-       };
-       unsigned char r;
-} sspcon2_t;
-
-static volatile sspcon2_t at sspcon2_addr sspcon2_b;
-#define SEN     sspcon2_b.sen
-#define RSEN    sspcon2_b.rsen
-#define PEN     sspcon2_b.pen
-#define RCEN    sspcon2_b.rcen
-#define ACKEN   sspcon2_b.acken
-#define ACKDT   sspcon2_b.ackdt
-#define ACKSTAT sspcon2_b.ackstat
-#define GCEN    sspcon2_b.gcen
-
-/* ---- SSPSTAT Bits ------------------------------------------------------- */
+  struct {
+    unsigned char T2CKPS0:1;
+    unsigned char T2CKPS1:1;
+    unsigned char TMR2ON:1;
+    unsigned char TOUTPS0:1;
+    unsigned char TOUTPS1:1;
+    unsigned char TOUTPS2:1;
+    unsigned char TOUTPS3:1;
+    unsigned char :1;
+  };
+} __T2CON_bits_t;
+extern volatile __T2CON_bits_t __at(T2CON_ADDR) T2CON_bits;
+
+#define T2CKPS0              T2CON_bits.T2CKPS0
+#define T2CKPS1              T2CON_bits.T2CKPS1
+#define TMR2ON               T2CON_bits.TMR2ON
+#define TOUTPS0              T2CON_bits.TOUTPS0
+#define TOUTPS1              T2CON_bits.TOUTPS1
+#define TOUTPS2              T2CON_bits.TOUTPS2
+#define TOUTPS3              T2CON_bits.TOUTPS3
+
+// ----- TRISA bits --------------------
 typedef union {
-       struct {
-               unsigned bf  :1; /* Buffer full status bit (Receive mode only) */
-               unsigned ua  :1; /* Update address bit used in I2C mode only */
-               unsigned r_w :1; /* Read write bit information used in I2C mode only */
-               unsigned s   :1; /* Start bit used in I2C mode only */
-               unsigned p   :1; /* Stop bit used in I2C mode only */
-               unsigned d_a :1; /* Data address bit used in I2C mode only */
-               unsigned cke :1; /* SPI clock select edge bit */
-               unsigned smp :1; /* Sample bit */
-       };
-       unsigned char r;
-} sspstat_t;
-
-static volatile sspstat_t at sspstat_addr sspstat_b;
-#define BF           sspstat_b.bf
-#define UA           sspstat_b.ua
-#define R_W          sspstat_b.r_w
-#define R            sspstat_b.r_w
-#define I2C_READ     sspstat_b.r_w
-#define NOT_W        sspstat_b.r_w
-#define NOT_WRITE    sspstat_b.r_w
-#define READ_WRITE   sspstat_b.r_w
-#define S            sspstat_b.s
-#define I2C_START    sspstat_b.s
-#define P            sspstat_b.p
-#define I2C_STOP     sspstat_b.p
-#define D_A          sspstat_b.d_a
-#define D            sspstat_b.d_a
-#define I2C_DATA     sspstat_b.d_a
-#define NOT_A        sspstat_b.d_a
-#define NOT_ADDRESS  sspstat_b.d_a
-#define DATA_ADDRESS sspstat_b.d_a
-#define CKE          sspstat_b.cke
-#define SMP          sspstat_b.smp
-
-/* ---- SSP Registers ------------------------------------------------------ */
-sfr at sspbuf_addr  sspbuf;
-sfr at sspcon_addr  sspcon;
-sfr at sspcon2_addr sspcon2;
-sfr at sspadd_addr  sspadd;
-sfr at sspstat_addr sspstat;
-sfr at sspstat_addr sspstat;
-sfr at sspcon2_addr sspcon2;
-sfr at sspcon_addr  sspcon;
-
-#define SSPBUF  sspbuf
-#define SSPCON  sspcon
-#define SSPCON2 sspcon2
-#define SSPADD  sspadd
-#define SSPSTAT sspstat
-
-/*****************************************************************************
-       USART
- *****************************************************************************/
-
-/* ---- RCSTA Bits --------------------------------------------------------- */
+  struct {
+    unsigned char TRISA0:1;
+    unsigned char TRISA1:1;
+    unsigned char TRISA2:1;
+    unsigned char TRISA3:1;
+    unsigned char TRISA4:1;
+    unsigned char TRISA5:1;
+    unsigned char :1;
+    unsigned char :1;
+  };
+} __TRISA_bits_t;
+extern volatile __TRISA_bits_t __at(TRISA_ADDR) TRISA_bits;
+
+#define TRISA0               TRISA_bits.TRISA0
+#define TRISA1               TRISA_bits.TRISA1
+#define TRISA2               TRISA_bits.TRISA2
+#define TRISA3               TRISA_bits.TRISA3
+#define TRISA4               TRISA_bits.TRISA4
+#define TRISA5               TRISA_bits.TRISA5
+
+// ----- TRISB bits --------------------
 typedef union {
-       struct {
-               unsigned rx9d  :1; /* 9the bit of received data (can be parity bit but must be calculated by user firmware */
-               unsigned oerr  :1; /* Overrun error bit */
-               unsigned ferr  :1; /* Framing error bit */
-               unsigned adden :1; /* Address detect enable bit */
-               unsigned cren  :1; /* Continuous receive enable bit */
-               unsigned sren  :1; /* Single receive enable bit */
-               unsigned rx9   :1; /* 9th bit receive enable bit */
-               unsigned spen  :1; /* Serial port enbale bit */
-       };
-       unsigned char r;
-} rcsta_t;
-
-static volatile rcsta_t at rcsta_addr rcsta_b;
-#define SPEN  rcsta_b.spen
-#define RX9   rcsta_b.rx9
-#define SREN  rcsta_b.sren
-#define CREN  rcsta_b.cren
-#define ADDEN rcsta_b.adden
-#define FERR  rcsta_b.ferr
-#define OERR  rcsta_b.oerr
-#define RX9D  rcsta_b.rx9d
-
-/* ---- TXSTA Bits --------------------------------------------------------- */
+  struct {
+    unsigned char TRISB0:1;
+    unsigned char TRISB1:1;
+    unsigned char TRISB2:1;
+    unsigned char TRISB3:1;
+    unsigned char TRISB4:1;
+    unsigned char TRISB5:1;
+    unsigned char TRISB6:1;
+    unsigned char TRISB7:1;
+  };
+} __TRISB_bits_t;
+extern volatile __TRISB_bits_t __at(TRISB_ADDR) TRISB_bits;
+
+#define TRISB0               TRISB_bits.TRISB0
+#define TRISB1               TRISB_bits.TRISB1
+#define TRISB2               TRISB_bits.TRISB2
+#define TRISB3               TRISB_bits.TRISB3
+#define TRISB4               TRISB_bits.TRISB4
+#define TRISB5               TRISB_bits.TRISB5
+#define TRISB6               TRISB_bits.TRISB6
+#define TRISB7               TRISB_bits.TRISB7
+
+// ----- TRISC bits --------------------
 typedef union {
-       struct {
-               unsigned tx9d :1; /* 9th bit of transmit data, can be parity */
-               unsigned trmt :1; /* Transmit shift register status bit */
-               unsigned brgh :1; /* High baud rate select bit */
-               unsigned      :1;
-               unsigned sync :1; /* USART mode select bit */
-               unsigned txen :1; /* Transmit enable bit */
-               unsigned tx9  :1; /* 9th bit transmit enable */
-               unsigned csrc :1; /* Clock source select bit */
-       };
-       unsigned char r;
-} txsta_t;
-
-static volatile txsta_t at txsta_addr txsta_b;
-#define CSRC txsta_b.csrc
-#define TX9  txsta_b.tx9
-#define TXEN txsta_b.txen
-#define SYNC txsta_b.sync
-#define BRGH txsta_b.brgh
-#define TRMT txsta_b.trmt
-#define TX9D txsta_b.tx9d
-
-/* ---- USART Registers ---------------------------------------------------- */
-sfr at spbrg_addr spbrg;
-sfr at rcreg_addr rcreg;
-sfr at txreg_addr txreg;
-sfr at rcsta_addr rcsta;
-sfr at txsta_addr txsta;
-#define SPBRG spbrg
-#define RCREG rcreg
-#define TXREG txreg
-#define RCSTA rcsta
-#define TXSTA txsta
-
-
-/*****************************************************************************
-       ADC
- *****************************************************************************/
-
-/* ---- ADCON0 Bits -------------------------------------------------------- */
+  struct {
+    unsigned char TRISC0:1;
+    unsigned char TRISC1:1;
+    unsigned char TRISC2:1;
+    unsigned char TRISC3:1;
+    unsigned char TRISC4:1;
+    unsigned char TRISC5:1;
+    unsigned char TRISC6:1;
+    unsigned char TRISC7:1;
+  };
+} __TRISC_bits_t;
+extern volatile __TRISC_bits_t __at(TRISC_ADDR) TRISC_bits;
+
+#define TRISC0               TRISC_bits.TRISC0
+#define TRISC1               TRISC_bits.TRISC1
+#define TRISC2               TRISC_bits.TRISC2
+#define TRISC3               TRISC_bits.TRISC3
+#define TRISC4               TRISC_bits.TRISC4
+#define TRISC5               TRISC_bits.TRISC5
+#define TRISC6               TRISC_bits.TRISC6
+#define TRISC7               TRISC_bits.TRISC7
+
+// ----- TRISD bits --------------------
 typedef union {
-       struct {
-               unsigned adon    :1; /* A/D on bit */
-               unsigned         :1;
-               unsigned go_done :1; /* A/D conversion start bit and not done status bit */
-               unsigned chs0    :1; /* Analog chanel select bits */
-               unsigned chs1    :1;
-               unsigned chs2    :1;
-               unsigned adcs0   :1; /* A/D conversion clock select bits */
-               unsigned adcs1   :1;
-       };
-       struct {
-               unsigned      :1;
-               unsigned      :1;
-               unsigned chs  :3; /* Analog chanel select bits */
-               unsigned adcs :2; /* A/D conversion clock select bits */
-       };
-       unsigned char r;
-} adcon0_t;
-
-static volatile adcon0_t at adcon0_addr adcon0_b;
-#define GO       adcon0_b.go_done
-#define NOT_DONE adcon0_b.go_done
-#define GO_DONE  adcon0_b.go_done
-#define ADON     adcon0_b.adon
-#define CHS0     adcon0_b.chs0
-#define CHS1     adcon0_b.chs1
-#define CHS2     adcon0_b.chs2
-#define ADCS0    adcon0_b.adcs0
-#define ADCS1    adcon0_b.adcs1
-
-/* ---- ADCON1 Bits -------------------------------------------------------- */
+  struct {
+    unsigned char TRISD0:1;
+    unsigned char TRISD1:1;
+    unsigned char TRISD2:1;
+    unsigned char TRISD3:1;
+    unsigned char TRISD4:1;
+    unsigned char TRISD5:1;
+    unsigned char TRISD6:1;
+    unsigned char TRISD7:1;
+  };
+} __TRISD_bits_t;
+extern volatile __TRISD_bits_t __at(TRISD_ADDR) TRISD_bits;
+
+#define TRISD0               TRISD_bits.TRISD0
+#define TRISD1               TRISD_bits.TRISD1
+#define TRISD2               TRISD_bits.TRISD2
+#define TRISD3               TRISD_bits.TRISD3
+#define TRISD4               TRISD_bits.TRISD4
+#define TRISD5               TRISD_bits.TRISD5
+#define TRISD6               TRISD_bits.TRISD6
+#define TRISD7               TRISD_bits.TRISD7
+
+// ----- TRISE bits --------------------
 typedef union {
-       struct {
-               unsigned pcfg0 :1; /* A/D port configuration control bits */
-               unsigned pcfg1 :1;
-               unsigned pcfg2 :1;
-               unsigned pcfg3 :1;
-               unsigned       :2;
-               unsigned adcs2 :1; /* A/D convertion clock select bit */
-               unsigned adfm  :1; /* A/D result format select bit */
-       };
-       struct {
-               unsigned pcfg :4; /* A/D port configuration control bits */
-       };
-       unsigned char r;
-} adcon1_t;
-
-static volatile adcon1_t at adcon1_addr adcon1_b;
-#define PCFG0 adcon1_b.pcfg0
-#define PCFG1 adcon1_b.pcfg1
-#define PCFG2 adcon1_b.pcfg2
-#define PCFG3 adcon1_b.pcfg3
-#define ADFM  adcon1_b.adfm
-
-/* ---- ADC Registers   ---------------------------------------------------- */
-sfr at adresh_addr adresh;
-sfr at adresh_addr adresl;
-sfr at adcon0_addr adcon0;
-sfr at adcon1_addr adcon1;
-#define ADRESH adresh
-#define ADRESL adresl
-#define ADCON0 adcon0
-#define ADCON1 adcon1
-
-
-/*****************************************************************************
-       EEPROM
- *****************************************************************************/
-
-/* ---- EECON1 Bits -------------------------------------------------------- */
+  struct {
+    unsigned char TRISE0:1;
+    unsigned char TRISE1:1;
+    unsigned char TRISE2:1;
+    unsigned char :1;
+    unsigned char PSPMODE:1;
+    unsigned char IBOV:1;
+    unsigned char OBF:1;
+    unsigned char IBF:1;
+  };
+} __TRISE_bits_t;
+extern volatile __TRISE_bits_t __at(TRISE_ADDR) TRISE_bits;
+
+#define TRISE0               TRISE_bits.TRISE0
+#define TRISE1               TRISE_bits.TRISE1
+#define TRISE2               TRISE_bits.TRISE2
+#define PSPMODE              TRISE_bits.PSPMODE
+#define IBOV                 TRISE_bits.IBOV
+#define OBF                  TRISE_bits.OBF
+#define IBF                  TRISE_bits.IBF
+
+// ----- TXSTA bits --------------------
 typedef union {
-       struct {
-               unsigned rd    :1; /* Read control bit */
-               unsigned wr    :1; /* Write control bit */
-               unsigned wren  :1; /* EEPROM write enable bit */
-               unsigned wrerr :1; /* EEPROM error flag bit */
-               unsigned       :3;
-               unsigned eepgd :1; /* Program data EEPROM select bit */
-       };
-       unsigned char r;
-} eecon1_t;
-
-static volatile eecon1_t at eecon1_addr eecon1_b;
-#define RD    eecon1_b.rd
-#define WR    eecon1_b.wr
-#define WREN  eecon1_b.wren
-#define WRERR eecon1_b.wrerr
-#define EEPGD eecon1_b.eepgd
-
-/* ---- EEPROM Registers   ------------------------------------------------- */
-sfr at eedata_addr eedata;
-sfr at eeadr_addr  eeadr;
-sfr at eedath_addr eedath;
-sfr at eeadrh_addr eeadrh;
-sfr at eecon1_addr eecon1;
-sfr at eecon2_addr eecon2;
-
-#define EEDATA eedata
-#define EEADR  eeadr
-#define EEDATH eedath
-#define EEADRH eeadrh
-#define EECON1 eecon1
-#define EECON2 eecon2
-
-
-/*****************************************************************************
-       Config Bits
- *****************************************************************************/
-enum {
-       cp_all         = 0x0fcf,
-       cp_half        = 0x1fdf,
-       cp_upper_256   = 0x2fef,
-       cp_off         = 0x3fff,
-       debug_on       = 0x37ff,
-       debug_off      = 0x3fff,
-       wrt_enable_on  = 0x3fff,
-       wrt_enable_off = 0x3dff,
-       cpd_on         = 0x3eff,
-       cpd_off        = 0x3fff,
-       lvp_on         = 0x3fff,
-       lvp_off        = 0x3f7f,
-       boden_on       = 0x3fff,
-       boden_off      = 0x3fbf,
-       pwrte_off      = 0x3fff,
-       pwrte_on       = 0x3ff7,
-       wdt_on         = 0x3fff,
-       wdt_off        = 0x3ffb,
-       lp_osc         = 0x3ffc,
-       xt_osc         = 0x3ffd,
-       hs_osc         = 0x3ffe,
-       rc_osc         = 0x3fff
-};
-
-#endif /* PIC16F877_H */
+  struct {
+    unsigned char TX9D:1;
+    unsigned char TRMT:1;
+    unsigned char BRGH:1;
+    unsigned char :1;
+    unsigned char SYNC:1;
+    unsigned char TXEN:1;
+    unsigned char TX9:1;
+    unsigned char CSRC:1;
+  };
+  struct {
+    unsigned char TXD8:1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char NOT_TX8:1;
+    unsigned char :1;
+  };
+  struct {
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char :1;
+    unsigned char TX8_9:1;
+    unsigned char :1;
+  };
+} __TXSTA_bits_t;
+extern volatile __TXSTA_bits_t __at(TXSTA_ADDR) TXSTA_bits;
+
+#define TX9D                 TXSTA_bits.TX9D
+#define TXD8                 TXSTA_bits.TXD8
+#define TRMT                 TXSTA_bits.TRMT
+#define BRGH                 TXSTA_bits.BRGH
+#define SYNC                 TXSTA_bits.SYNC
+#define TXEN                 TXSTA_bits.TXEN
+#define TX9                  TXSTA_bits.TX9
+#define NOT_TX8              TXSTA_bits.NOT_TX8
+#define TX8_9                TXSTA_bits.TX8_9
+#define CSRC                 TXSTA_bits.CSRC
+
+#endif