* as/mcs51/asexpr.c (expr): disabled warning "not in .flat24 mode",
[fw/sdcc] / src / pic16 / device.c
index 3f730a81984b03e050341fed666b7006040e5672..8ab5595c5443fed586ea1ef6332bd4535534066f 100644 (file)
@@ -43,7 +43,7 @@
 
 static PIC16_device Pics16[] = {
 //  {
-//    {"p18f242", "18f242", "pic18f242", "f242"},              // aliases
+//    {"p18f242", "18f242", "pic18f242", "f242", "18F242"},            // aliases
 //    0,
 //    0x300,                                           // RAMsize
 //    0,
@@ -73,8 +73,8 @@ static PIC16_device Pics16[] = {
       0x30000d,
       { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
       { -1, 0, 0xff } /* 4 */  , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
-      { -1, 0, 0xff } /* 7 */  , { 0x03, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
-      { 0x03, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x03, 0, 0xff } /* c */ , 
+      { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
+      { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
       { 0x40, 0, 0xff } /* d */  }
     },
     { 0x200000, 0x200007, 
@@ -95,8 +95,8 @@ static PIC16_device Pics16[] = {
       0x30000d,
       { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
       { -1, 0, 0xff } /* 4 */  , { -1, 0, 0xff } /* 5 */  , { 0x85, 0, 0xff } /* 6 */ , 
-      { -1, 0, 0xff } /* 7 */  , { 0x03, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
-      { 0x03, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x03, 0, 0xff } /* c */ , 
+      { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
+      { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
       { 0x40, 0, 0xff } /* d */  }
     },
     { 0x200000, 0x200007, 
@@ -161,8 +161,8 @@ static PIC16_device Pics16[] = {
       0x30000d,
       { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
       { -1, 0, 0xff } /* 4 */  , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
-      { -1, 0, 0xff } /* 7 */  , { 0x03, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
-      { 0x03, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x03, 0, 0xff } /* c */ , 
+      { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
+      { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
       { 0x40, 0, 0xff } /* d */  }
     },
     { 0x200000, 0x200007, 
@@ -183,8 +183,8 @@ static PIC16_device Pics16[] = {
       0x30000d,
       { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
       { -1, 0, 0xff } /* 4 */  , { -1, 0, 0xff } /* 5 */  , { 0x85, 0, 0xff } /* 6 */ , 
-      { -1, 0, 0xff } /* 7 */  , { 0x03, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
-      { 0x03, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x03, 0, 0xff } /* c */ , 
+      { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
+      { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
       { 0x40, 0, 0xff } /* d */  }
     },
     { 0x200000, 0x200007, 
@@ -271,8 +271,74 @@ static PIC16_device Pics16[] = {
       0x30000d,
       { { 0xcf, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x1f, 0, 0xff } /* 3 */ , 
       { -1, 0, 0xff } /* 4 */  , { 0x83, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
-      { -1, 0, 0xff } /* 7 */  , { 0x03, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
-      { 0x03, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x03, 0, 0xff } /* c */ , 
+      { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
+      { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
+      { 0x40, 0, 0xff } /* d */  }
+    },
+    { 0x200000, 0x200007, 
+      { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, 
+        { 0, 0 }, { 0, 0 }, { 0, 0 } }
+    }
+  },
+  {
+    {"p18f2455", "18f2455", "pic18f2455", "f2455"},
+    0,
+    0x800,     /* 2048 */
+    0x60,
+    0,
+    { 0xf62, 0xfff },  /* PIC18F2455 range of SFR's */
+    {
+    /* PIC18F2455 configuration words */
+      0x300000,
+      0x30000d,
+      { { 0x3f, 0, 0xff } /* 0 */ , { 0xcf, 0, 0xff } /* 1 */ , { 0x3f, 0, 0xff } /* 2 */ , 
+      { 0x1f, 0, 0xff } /* 3 */ , { -1, 0, 0xff } /* 4 */  , { 0x87, 0, 0xff } /* 5 */ , 
+      { 0xe5, 0, 0xff } /* 6 */ , { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , 
+      { 0xc0, 0, 0xff } /* 9 */ , { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , 
+      { 0x0f, 0, 0xff } /* c */ , { 0x40, 0, 0xff } /* d */  }
+    },
+    { 0x200000, 0x200007, 
+      { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, 
+        { 0, 0 }, { 0, 0 }, { 0, 0 } }
+    }
+  },
+  {
+    {"p18f2550", "18f2550", "pic18f2550", "f2550"},
+    0,
+    0x800,     /* 2048 */
+    0x60,
+    0,
+    { 0xf62, 0xfff },  /* PIC18F2550 range of SFR's */
+    {
+    /* PIC18F2550 configuration words */
+      0x300000,
+      0x30000d,
+      { { 0x3f, 0, 0xff } /* 0 */ , { 0xcf, 0, 0xff } /* 1 */ , { 0x3f, 0, 0xff } /* 2 */ , 
+      { 0x1f, 0, 0xff } /* 3 */ , { -1, 0, 0xff } /* 4 */  , { 0x87, 0, 0xff } /* 5 */ , 
+      { 0xe5, 0, 0xff } /* 6 */ , { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , 
+      { 0xc0, 0, 0xff } /* 9 */ , { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , 
+      { 0x0f, 0, 0xff } /* c */ , { 0x40, 0, 0xff } /* d */  }
+    },
+    { 0x200000, 0x200007, 
+      { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, 
+        { 0, 0 }, { 0, 0 }, { 0, 0 } }
+    }
+  },
+  {
+    {"p18f4331", "18f4331", "pic18f4331", "f4331"},
+    0,
+    0x300,     /* 768 */
+    0x60,
+    0,
+    { 0xf60, 0xfff },  /* PIC18F4331 range of SFR's */
+    {
+    /* PIC18F4331 configuration words */
+      0x300001,
+      0x30000d,
+      { { 0xcf, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x3f, 0, 0xff } /* 3 */ , 
+      { 0x3c, 0, 0xff } /* 4 */ , { 0x9d, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
+      { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
+      { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
       { 0x40, 0, 0xff } /* d */  }
     },
     { 0x200000, 0x200007, 
@@ -280,6 +346,50 @@ static PIC16_device Pics16[] = {
         { 0, 0 }, { 0, 0 }, { 0, 0 } }
     }
   },
+  {
+    {"p18f4455", "18f4455", "pic18f4455", "f4455"},
+    0,
+    0x800,     /* 2048 */
+    0x60,
+    0,
+    { 0xf62, 0xfff },  /* PIC18F4455 range of SFR's */
+    {
+    /* PIC18F4455 configuration words */
+      0x300000,
+      0x30000d,
+      { { 0x3f, 0, 0xff } /* 0 */ , { 0xcf, 0, 0xff } /* 1 */ , { 0x3f, 0, 0xff } /* 2 */ , 
+      { 0x1f, 0, 0xff } /* 3 */ , { -1, 0, 0xff } /* 4 */  , { 0x87, 0, 0xff } /* 5 */ , 
+      { 0xe5, 0, 0xff } /* 6 */ , { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , 
+      { 0xc0, 0, 0xff } /* 9 */ , { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , 
+      { 0x0f, 0, 0xff } /* c */ , { 0x40, 0, 0xff } /* d */  }
+    },
+    { 0x200000, 0x200007, 
+      { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, 
+        { 0, 0 }, { 0, 0 }, { 0, 0 } }
+    }
+  },
+  {
+    {"p18f4520", "18f4520", "pic18f4520", "f4520"},
+    0,
+    0x1000,    /* 4096 */
+    0x80,
+    0,
+    { 0xf80, 0xfff },  /* PIC18F4520 range of SFR's */
+    {
+    /* PIC18F4520 configuration words */
+      0x300000,
+      0x30000d,
+      { { 0x3f, 0, 0xff } /* 0 */ , { 0xcf, 0, 0xff } /* 1 */ , { 0x1f, 0, 0xff } /* 2 */ , 
+      { 0x1f, 0, 0xff } /* 3 */ , { -1, 0, 0xff } /* 4 */  , { 0x87, 0, 0xff } /* 5 */ , 
+      { 0xc5, 0, 0xff } /* 6 */ , { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , 
+      { 0xc0, 0, 0xff } /* 9 */ , { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , 
+      { 0x0f, 0, 0xff } /* c */ , { 0x40, 0, 0xff } /* d */  }
+    },
+    { 0x200000, 0x200007, 
+      { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, 
+        { 0, 0 }, { 0, 0 }, { 0, 0 } }
+    }
+  },
   {
     {"p18f6520", "18f6520", "pic18f6520", "f6520"},
     0,
@@ -292,9 +402,9 @@ static PIC16_device Pics16[] = {
       0x300001,
       0x30000d,
       { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
-      { 0x80, 0, 0xff } /* 4 */ , { 0x88, 0, 0xff } /* 5 */ , { -1, 0, 0xff } /* 6 */  , 
-      { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
-      { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
+      { 0x83, 0, 0xff } /* 4 */ , { 0x03, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
+      { -1, 0, 0xff } /* 7 */  , { 0xff, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
+      { 0xff, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0xff, 0, 0xff } /* c */ , 
       { 0x40, 0, 0xff } /* d */  }
     },
     { 0x200000, 0x200007, 
@@ -314,9 +424,9 @@ static PIC16_device Pics16[] = {
       0x300001,
       0x30000d,
       { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
-      { -1, 0, 0xff } /* 4 */  , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
-      { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
-      { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
+      { 0x83, 0, 0xff } /* 4 */ , { 0x03, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
+      { -1, 0, 0xff } /* 7 */  , { 0xff, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
+      { 0xff, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0xff, 0, 0xff } /* c */ , 
       { 0x40, 0, 0xff } /* d */  }
     },
     { 0x200000, 0x200007, 
@@ -330,13 +440,13 @@ static PIC16_device Pics16[] = {
     0xf00,     /* 3840 */
     0x60,
     0,
-    { 0xf00, 0xfff },  /* PIC18F6680 range of SFR's */
+    { 0xd60, 0xfff },  /* PIC18F6680 range of SFR's */
     {
     /* PIC18F6680 configuration words */
       0x300001,
       0x30000d,
       { { 0x2f, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x1f, 0, 0xff } /* 3 */ , 
-      { -1, 0, 0xff } /* 4 */  , { 0x83, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
+      { 0x83, 0, 0xff } /* 4 */ , { 0x81, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
       { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
       { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
       { 0x40, 0, 0xff } /* d */  }
@@ -358,7 +468,7 @@ static PIC16_device Pics16[] = {
       0x300001,
       0x30000d,
       { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
-      { -1, 0, 0xff } /* 4 */  , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
+      { 0x83, 0, 0xff } /* 4 */ , { 0x03, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
       { -1, 0, 0xff } /* 7 */  , { 0xff, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
       { 0xff, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0xff, 0, 0xff } /* c */ , 
       { 0x40, 0, 0xff } /* d */  }
@@ -380,9 +490,9 @@ static PIC16_device Pics16[] = {
       0x300001,
       0x30000d,
       { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
-      { 0x83, 0, 0xff } /* 4 */ , { 0x88, 0, 0xff } /* 5 */ , { -1, 0, 0xff } /* 6 */  , 
-      { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
-      { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
+      { 0x83, 0, 0xff } /* 4 */ , { 0x03, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
+      { -1, 0, 0xff } /* 7 */  , { 0xff, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
+      { 0xff, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0xff, 0, 0xff } /* c */ , 
       { 0x40, 0, 0xff } /* d */  }
     },
     { 0x200000, 0x200007, 
@@ -402,9 +512,9 @@ static PIC16_device Pics16[] = {
       0x300001,
       0x30000d,
       { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
-      { 0x83, 0, 0xff } /* 4 */ , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
-      { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
-      { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
+      { 0x83, 0, 0xff } /* 4 */ , { 0x03, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
+      { -1, 0, 0xff } /* 7 */  , { 0xff, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
+      { 0xff, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0xff, 0, 0xff } /* c */ , 
       { 0x40, 0, 0xff } /* d */  }
     },
     { 0x200000, 0x200007, 
@@ -417,14 +527,14 @@ static PIC16_device Pics16[] = {
     0,
     0xf00,     /* 3840 */
     0x60,
-    0,
-    { 0xf00, 0xfff },  /* PIC18F8680 range of SFR's */
+    1,
+    { 0xd60, 0xfff },  /* PIC18F8680 range of SFR's */
     {
     /* PIC18F8680 configuration words */
       0x300001,
       0x30000d,
       { { 0x2f, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x1f, 0, 0xff } /* 3 */ , 
-      { 0x83, 0, 0xff } /* 4 */ , { 0x83, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
+      { 0x83, 0, 0xff } /* 4 */ , { 0x81, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
       { -1, 0, 0xff } /* 7 */  , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
       { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ , 
       { 0x40, 0, 0xff } /* d */  }
@@ -446,7 +556,7 @@ static PIC16_device Pics16[] = {
       0x300001,
       0x30000d,
       { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ , 
-      { 0x83, 0, 0xff } /* 4 */ , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
+      { 0x83, 0, 0xff } /* 4 */ , { 0x03, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ , 
       { -1, 0, 0xff } /* 7 */  , { 0xff, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ , 
       { 0xff, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0xff, 0, 0xff } /* c */ , 
       { 0x40, 0, 0xff } /* d */  }
@@ -461,6 +571,8 @@ static PIC16_device Pics16[] = {
 
 static int num_of_supported_PICS = sizeof(Pics16)/sizeof(PIC16_device);
 
+stats_t statistics = { 0, 0, 0, 0 };
+
 #define DEFAULT_PIC "452"
 
 PIC16_device *pic16=NULL;
@@ -514,6 +626,7 @@ void pic16_dump_access(FILE *of, set *section)
        fprintf(of, "\tudata_acs\n");
        for(; r; r = setNextItem(section)) {
                fprintf(of, "%s\tres\t%d\n", r->name, r->size);
+               statistics.adsize += r->size;
        }
 }
 
@@ -561,8 +674,9 @@ int symCompare(const void *a, const void *b)
 void pic16_dump_usection(FILE *of, set *section, int fix)
 {
   static int abs_usection_no=0;
+  static unsigned int usection_no=0;
   regs *r, *rprev;
-  int init_addr, i;
+  unsigned int init_addr, i;
   regs **rlist;
   regs *r1;
 
@@ -574,7 +688,7 @@ void pic16_dump_usection(FILE *of, set *section, int fix)
        }
        
        if(!i) {
-               if(rlist)free(rlist);
+               if(rlist)Safe_free(rlist);
          return;
        }
 
@@ -582,12 +696,24 @@ void pic16_dump_usection(FILE *of, set *section, int fix)
        qsort(rlist, i  /*elementsInSet(section)*/, sizeof(regs *), regCompare);
        
        if(!fix) {
+
+#define EMIT_SINGLE_UDATA_SECTION      0
+#if EMIT_SINGLE_UDATA_SECTION
                fprintf(of, "\n\n\tudata\n");
                for(r = setFirstItem(section); r; r = setNextItem(section)) {
                        fprintf(of, "%s\tres\t%d\n", r->name, r->size);
+                       statistics.udsize += r->size;
                }
+#else
+               for(r = setFirstItem(section); r; r = setNextItem(section)) {
+                       //fprintf(of, "\nudata_%s_%s\tudata\n", moduleName, r->name);
+                       fprintf(of, "\nudata_%s_%u\tudata\n", moduleName, usection_no++);
+                       fprintf(of, "%s\tres\t%d\n", r->name, r->size);
+                       statistics.udsize += r->size;
+               }
+#endif
        } else {
-         int j=0;
+         unsigned int j=0;
          int deb_addr=0;
 
                rprev = NULL;
@@ -611,12 +737,13 @@ void pic16_dump_usection(FILE *of, set *section, int fix)
                        } else {
                                fprintf(of, "%s\tres\t%d\n", r->name, r->size);
                                deb_addr += r->size;
+                               statistics.udsize += r->size;
                        }
                        
                        rprev = r;
                }
        }
-       free(rlist);
+       Safe_free(rlist);
 }
 
 void pic16_dump_gsection(FILE *of, set *sections)
@@ -625,6 +752,7 @@ void pic16_dump_gsection(FILE *of, set *sections)
   sectName *sname;
 
        for(sname = setFirstItem(sections); sname; sname = setNextItem(sections)) {
+               if(!strcmp(sname->name, "access"))continue;
                fprintf(of, "\n\n%s\tudata\n", sname->name);
 
                for(r=setFirstItem(sname->regsSet); r; r=setNextItem(sname->regsSet)) {
@@ -633,6 +761,7 @@ void pic16_dump_gsection(FILE *of, set *sections)
                                r->name, sname->name, sname);
 #endif
                        fprintf(of, "%s\tres\t%d\n", r->name, r->size);
+                       statistics.udsize += r->size;
                }
        }
 }
@@ -646,7 +775,7 @@ void pic16_dump_isection(FILE *of, set *section, int fix)
 {
   static int abs_isection_no=0;
   symbol *s, *sprev;
-  int init_addr, i;
+  unsigned int init_addr, i;
   symbol **slist;
 
        /* put all symbols in an array */
@@ -657,7 +786,7 @@ void pic16_dump_isection(FILE *of, set *section, int fix)
        }
        
        if(!i) {
-               if(slist)free(slist);
+               if(slist)Safe_free(slist);
          return;
        }
 
@@ -687,7 +816,7 @@ void pic16_dump_isection(FILE *of, set *section, int fix)
                                
                }
        } else {
-         int j=0;
+         unsigned int j=0;
          symbol *s1;
          
                sprev = NULL;
@@ -723,7 +852,7 @@ void pic16_dump_isection(FILE *of, set *section, int fix)
                        sprev = s;
                }
        }
-       free(slist);
+       Safe_free(slist);
 }
 
 
@@ -744,17 +873,19 @@ void pic16_dump_int_registers(FILE *of, set *section)
        qsort(rlist, elementsInSet(section), sizeof(regs *), regCompare);
        
        if(!i) {
-               if(rlist)free(rlist);
+               if(rlist)Safe_free(rlist);
          return;
        }
        
        fprintf(of, "\n\n; Internal registers\n");
        
        fprintf(of, "%s\tudata_ovr\t0x0000\n", ".registers");
-       for(r = setFirstItem(section); r; r = setNextItem(section))
+       for(r = setFirstItem(section); r; r = setNextItem(section)) {
                fprintf(of, "%s\tres\t%d\n", r->name, r->size);
+               statistics.intsize += r->size;
+       }
 
-       free(rlist);
+       Safe_free(rlist);
 }
 
 
@@ -1020,8 +1151,15 @@ void pic16_groupRegistersInSection(set *regset)
                                if(!strcmp(ssym->name, reg->name)) {
 //                                     fprintf(stderr, "%s:%d section found %s (%p) with var %s\n",
 //                                                     __FILE__, __LINE__, ssym->section->name, ssym->section, ssym->name);
-                                       addSet(&ssym->section->regsSet, reg);
-                                       docontinue=1;
+                                       if(strcmp(ssym->section->name, "access")) {
+                                               addSet(&ssym->section->regsSet, reg);
+                                               docontinue=1;
+                                               break;
+                                       } else {
+                                               docontinue=0;
+                                               reg->accessBank = 1;
+                                               break;
+                                       }
                                }
                        }
 
@@ -1040,7 +1178,8 @@ void pic16_groupRegistersInSection(set *regset)
                                        checkAddReg(&pic16_int_regs, reg);
                                else {
                                        if(reg->accessBank) {
-                                               checkAddReg(&pic16_acs_udata, reg);
+                                               if(reg->alias != 0x40)
+                                                       checkAddReg(&pic16_acs_udata, reg);
                                        } else
                                                checkAddReg(&pic16_rel_udata, reg);
                                }
@@ -1076,11 +1215,14 @@ void pic16_assignConfigWordValue(int address, unsigned int value)
                                        (pic16->cwInfo.crInfo[i].mask) & (~value));
 #endif
 
+#if 0
                        if((((pic16->cwInfo.crInfo[i].mask) & (~value))&0xff) != ((~value)&0xff)) {
                                fprintf(stderr, "%s:%d a wrong value has been given for configuration register 0x%x\n",
                                        __FILE__, __LINE__, address);
                                        return;
                        }
+#endif
+
                         pic16->cwInfo.crInfo[i].value = value;
                         pic16->cwInfo.crInfo[i].emit = 1;
                         return;