* device/include/pic16/pic16devices.txt,
authortecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 25 Nov 2008 01:47:40 +0000 (01:47 +0000)
committertecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 25 Nov 2008 01:47:40 +0000 (01:47 +0000)
  sdcc/src/pic16/device.c,
  sdcc/src/pic16/device.h: implicitly disable XINST
  whenever CONFIG4L is set via an additional optional
  argument to the configword directive in pic16devices.txt

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5276 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
device/include/pic16/pic16devices.txt
src/pic16/device.c
src/pic16/device.h

index 7066fec295e60ab8362b6a4b23423e039b544d16..37ed4e16c08ee6e09aec6a0a0cdfb25b9306a3ff 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-11-25 Raphael Neider <rneider AT web.de>
+
+       * device/include/pic16/pic16devices.txt,
+         sdcc/src/pic16/device.c,
+         sdcc/src/pic16/device.h: implicitly disable XINST
+         whenever CONFIG4L is set via an additional optional
+         argument to the configword directive in pic16devices.txt
+
 2008-11-24 Raphael Neider <rneider AT web.de>
 
        * device/lib/pic16/configure.ac,
index 7f1a54596ca0f6ea1be0fd26bc924777161c226b..45aec7d46521c2eb45bf43e150158f0e79e553f6 100644 (file)
 # configrange <first> <last>
 #       Configuration registers occupy addresses <first> to <last> (both
 #       included).
-# configword <address> <mask> <value>
+# configword <address> <mask> <value> [<and-mask>]
 #       The config word at address <address> only implements the bits
 #       indicated via <mask> (all others will be forced to 0 by the
 #       compiler).
 #       Unless overridden in C code, use the given default <value>.
+#       The optional <and-mask> will be applied to the value just before
+#       emitting it into the .asm file (used to disable XINST by default).
 # idlocrange <first> <last>
 #       ID locations occupy addresses <first> to <last> (both included).
 # idword <address> <value>
@@ -83,7 +85,7 @@ configword  0x300001 0xcf 0x37
 configword  0x300002 0x1f 0xff
 configword  0x300003 0x1f 0xff
 configword  0x300005 0x87 0xfb
-configword  0x300006 0xf5 0x8f
+configword  0x300006 0xf5 0x8f 0xbf
 configword  0x300008 0x03 0xff
 configword  0x300009 0xc0 0xff
 configword  0x30000a 0x03 0xff
@@ -128,7 +130,7 @@ configword  0x300001 0xcf 0x37
 configword  0x300002 0x1f 0xff
 configword  0x300003 0x1f 0xfb
 configword  0x300005 0x87 0xfb
-configword  0x300006 0xc5 0xbf
+configword  0x300006 0xc5 0xbf 0xbf
 configword  0x300008 0x0f 0xff
 configword  0x300009 0x40 0xff
 configword  0x30000a 0x0f 0xff
@@ -164,7 +166,7 @@ configword  0x300001 0xcf 0x07
 configword  0x300002 0x1f 0xff
 configword  0x300003 0x1f 0xff
 configword  0x300005 0x87 0xfb
-configword  0x300006 0xc5 0xbf
+configword  0x300006 0xc5 0xbf 0xbf
 configword  0x300008 0x0f 0xff
 configword  0x300009 0xc0 0xff
 configword  0x30000a 0x0f 0xff
@@ -182,7 +184,7 @@ configword  0x300001 0xcf 0x07
 configword  0x300002 0x1f 0xff
 configword  0x300003 0x1f 0xff
 configword  0x300005 0x87 0xfb
-configword  0x300006 0xc5 0xbf
+configword  0x300006 0xc5 0xbf 0xbf
 configword  0x300008 0x0f 0xff
 configword  0x300009 0xc0 0xff
 configword  0x30000a 0x0f 0xff
@@ -206,7 +208,7 @@ configword  0x300001 0xcf 0x37
 configword  0x300002 0x3f 0xdf
 configword  0x300003 0x1f 0xff
 configword  0x300005 0x86 0xfb
-configword  0x300006 0xed 0x97
+configword  0x300006 0xed 0x97 0xbf
 configword  0x300008 0x03 0xff
 configword  0x300009 0x40 0xff
 configword  0x30000a 0x03 0xff
@@ -224,7 +226,7 @@ configword  0x300001 0xcf 0x35
 configword  0x300002 0x3f 0xdf
 configword  0x300003 0x1f 0xff
 configword  0x300005 0x87 0xfb
-configword  0x300006 0xe5 0x9f
+configword  0x300006 0xe5 0x9f 0xbf
 configword  0x300008 0x0f 0xff
 configword  0x300009 0xc0 0xff
 configword  0x30000a 0x0f 0xff
@@ -259,7 +261,7 @@ configword  0x300001 0xcf 0x37
 configword  0x300002 0x1f 0xff
 configword  0x300003 0x1f 0xff
 configword  0x300005 0x86 0xfb
-configword  0x300006 0xd5 0xaf
+configword  0x300006 0xd5 0xaf 0xbf
 configword  0x300008 0x0f 0xff
 configword  0x300009 0xc0 0xff
 configword  0x30000a 0x0f 0xff
@@ -314,7 +316,7 @@ configword  0x300001 0xcf 0x37
 configword  0x300002 0x1f 0xff
 configword  0x300003 0x1f 0xff
 configword  0x300005 0x87 0xfb
-configword  0x300006 0xc5 0xbf
+configword  0x300006 0xc5 0xbf 0xbf
 configword  0x300008 0x0f 0xff
 configword  0x300009 0xc0 0xff
 configword  0x30000a 0x0f 0xff
@@ -346,7 +348,7 @@ configword  0x300001 0xcf 0x37
 configword  0x300002 0x1f 0xff
 configword  0x300003 0x1f 0xff
 configword  0x300005 0x86 0xfb
-configword  0x300006 0xf5 0x8f
+configword  0x300006 0xf5 0x8f 0xbf
 configword  0x300008 0x0f 0xff
 configword  0x300009 0xc0 0xff
 configword  0x30000a 0x0f 0xff
@@ -381,7 +383,7 @@ configword  0x300001 0xcf 0x37
 configword  0x300002 0x1f 0xff
 configword  0x300003 0x1f 0xff
 configword  0x300005 0x86 0xfb
-configword  0x300006 0xf5 0x8f
+configword  0x300006 0xf5 0x8f 0xbf
 configword  0x300008 0x3f 0xff
 configword  0x300009 0xc0 0xff
 configword  0x30000a 0x3f 0xff
index 310af6f1737091f159fc2fdc120e97c152275809..589b89da7070060c3375001ed8a94a1ef1500cf7 100644 (file)
@@ -548,22 +548,25 @@ get_line (FILE *file)
 static char *
 strip_comment (char *line)
 {
-    char *l = line;
-    char c;
+  char *l = line;
+  char c;
 
-    if (!line) {
-        return (line);
+  if (!line)
+    {
+      return (line);
     } // if
 
-    while (0 != (c = *l)) {
-        if ('#' == c) {
-            *l = 0;
-            return (line);
+  while (0 != (c = *l))
+    {
+      if ('#' == c)
+        {
+          *l = 0;
+          return (line);
         } // if
-        l++;
+      l++;
     } // while
 
-    return (line);
+  return (line);
 }
 
 /**
@@ -589,192 +592,266 @@ strip_comment (char *line)
 static PIC16_device *
 pic16_find_device(const char *name)
 {
-    const char *path;
-    char buffer[PATH_MAX];
-    char *line, *key;
-    const char *sep = " \t\n\r";
-    FILE *f = NULL;
-    PIC16_device *d = NULL, *template;
-    PIC16_device *head = NULL, *tail = NULL;
-    set *_sets[] = { userIncDirsSet, includeDirsSet };
-    set **sets = &_sets[0];
-    int lineno = 0;
-    int res, i;
-    int val[3];
-
-    if (!devices) {
-        //printf("%s: searching %s\n", __func__, DEVICE_FILE_NAME);
-
-        // locate the specification file in the include search paths
-        for (i = 0; (NULL == f) && (i < 2); i++) {
-            for (path = setFirstItem(sets[i]);
-                    (NULL == f) && path;
-                    path = setNextItem(sets[i]))
+  const char *path;
+  char buffer[PATH_MAX];
+  char *line, *key;
+  const char *sep = " \t\n\r";
+  FILE *f = NULL;
+  PIC16_device *d = NULL, *template;
+  PIC16_device *head = NULL, *tail = NULL;
+  set *_sets[] = { userIncDirsSet, includeDirsSet };
+  set **sets = &_sets[0];
+  int lineno = 0;
+  int res, i;
+  int val[4];
+
+  if (!devices)
+    {
+      //printf("%s: searching %s\n", __func__, DEVICE_FILE_NAME);
+
+      // locate the specification file in the include search paths
+      for (i = 0; (NULL == f) && (i < 2); i++)
+        {
+          for (path = setFirstItem(sets[i]);
+               (NULL == f) && path;
+               path = setNextItem(sets[i]))
             {
-                SNPRINTF(&buffer[0], PATH_MAX, "%s%s%s",
-                        path, DIR_SEPARATOR_STRING, DEVICE_FILE_NAME);
-                //printf("%s: checking %s\n", __func__, &buffer[0]);
-                f = fopen(&buffer[0], "r");
+              SNPRINTF(&buffer[0], PATH_MAX, "%s%s%s",
+                       path, DIR_SEPARATOR_STRING, DEVICE_FILE_NAME);
+              //printf("%s: checking %s\n", __func__, &buffer[0]);
+              f = fopen(&buffer[0], "r");
             } // for
-        } // while
+        } // for
     } // if
 
-    if (devices) {
-        // list already set up, nothing to do
-    } else if (NULL == f) {
-        fprintf(stderr, "ERROR: device list %s not found, specify its path via -I<path>\n", DEVICE_FILE_NAME);
-        d = &default_device;
-    } else {
-        // parse the specification file and construct a linked list of
-        // supported devices
-        d = NULL;
-        while (NULL != (line = get_line(f))) {
-            strip_comment(line);
-            //printf("%s: read %s\n", __func__, line);
-            lineno++;
-            key = strtok(line, sep);
-            if (!key) {
-                // empty line---ignore
-            } else if (0 == strcmp(key, "name")) {
-                // name %<name>s
-                if (d) {
-                    if (tail) {
-                        tail->next = d;
-                    } else {
-                        head = d;
+  if (devices)
+    {
+      // list already set up, nothing to do
+    }
+  else if (NULL == f)
+    {
+      fprintf(stderr, "ERROR: device list %s not found, specify its path via -I<path>\n",
+              DEVICE_FILE_NAME);
+      d = &default_device;
+    }
+  else
+    {
+      // parse the specification file and construct a linked list of
+      // supported devices
+      d = NULL;
+      while (NULL != (line = get_line(f)))
+        {
+          strip_comment(line);
+          //printf("%s: read %s\n", __func__, line);
+          lineno++;
+          key = strtok(line, sep);
+          if (!key)
+            {
+              // empty line---ignore
+            }
+          else if (0 == strcmp(key, "name"))
+            {
+              // name %<name>s
+              if (d)
+                {
+                  if (tail)
+                    {
+                      tail->next = d;
+                    }
+                  else
+                    {
+                      head = d;
                     } // if
-                    tail = d;
-                    d = NULL;
+                  tail = d;
+                  d = NULL;
                 } // if
 
-                res = sscanf(&line[1+strlen(key)], " %16s", &buffer[3]);
-                if ((1 < res) || (3 > strlen(&buffer[3]))) {
-                    SYNTAX("<name> (e.g., 18f452) expected.");
-                } else {
-                    d = Safe_calloc(1, sizeof(PIC16_device));
-
-                    // { "p18f452", "18f452", "pic18f452", "f452" }
-                    buffer[0] = 'p';
-                    buffer[1] = 'i';
-                    buffer[2] = 'c';
-                    d->name[3] = Safe_strdup(&buffer[5]);
-                    d->name[2] = Safe_strdup(&buffer[0]);
-                    d->name[1] = Safe_strdup(&buffer[3]);
-                    buffer[2] = 'p';
-                    d->name[0] = Safe_strdup(&buffer[2]);
+              res = sscanf(&line[1 + strlen(key)], " %16s", &buffer[3]);
+              if ((1 < res) || (3 > strlen(&buffer[3])))
+                {
+                  SYNTAX("<name> (e.g., 18f452) expected.");
+                }
+              else
+                {
+                  d = Safe_calloc(1, sizeof(PIC16_device));
+
+                  // { "p18f452", "18f452", "pic18f452", "f452" }
+                  buffer[0] = 'p';
+                  buffer[1] = 'i';
+                  buffer[2] = 'c';
+                  d->name[3] = Safe_strdup(&buffer[5]);
+                  d->name[2] = Safe_strdup(&buffer[0]);
+                  d->name[1] = Safe_strdup(&buffer[3]);
+                  buffer[2] = 'p';
+                  d->name[0] = Safe_strdup(&buffer[2]);
                 } // if
-            } else if (0 == strcmp(key, "using")) {
-                // using %<name>s
-                res = sscanf(&line[1+strlen(key)], " %16s", &buffer[0]);
-                if ((1 < res) || (3 > strlen(&buffer[3]))) {
-                    SYNTAX("<name> (e.g., 18f452) expected.");
-                } else {
-                    template = find_in_list(&buffer[0], head);
-                    if (!template) {
-                        SYNTAX("<name> (e.g., 18f452) expected.");
-                    } else {
-                        memcpy(&d->RAMsize, &template->RAMsize,
-                                ((char *)&d->next) - ((char *)&d->RAMsize));
+            }
+          else if (0 == strcmp(key, "using"))
+            {
+              // using %<name>s
+              res = sscanf(&line[1 + strlen(key)], " %16s", &buffer[0]);
+              if ((1 < res) || (3 > strlen(&buffer[3])))
+                {
+                  SYNTAX("<name> (e.g., 18f452) expected.");
+                }
+              else
+                {
+                  template = find_in_list(&buffer[0], head);
+                  if (!template)
+                    {
+                      SYNTAX("<name> (e.g., 18f452) expected.");
+                    }
+                  else
+                    {
+                      memcpy(&d->RAMsize, &template->RAMsize,
+                             ((char *)&d->next) - ((char *)&d->RAMsize));
                     } // if
                 } // if
-            } else if (0 == strcmp(key, "ramsize")) {
-                // ramsize %<bytes>i
-                res = sscanf(&line[1+strlen(key)], " %i", &val[0]);
-                if (res < 1) {
-                    SYNTAX("<bytes> (e.g., 256) expected.");
-                } else {
-                    d->RAMsize = val[0];
+            }
+          else if (0 == strcmp(key, "ramsize"))
+            {
+              // ramsize %<bytes>i
+              res = sscanf(&line[1 + strlen(key)], " %i", &val[0]);
+              if (res < 1)
+                {
+                  SYNTAX("<bytes> (e.g., 256) expected.");
+                }
+              else
+                {
+                  d->RAMsize = val[0];
                 } // if
-            } else if (0 == strcmp(key, "split")) {
-                // split %<offset>i
-                res = sscanf(&line[1+strlen(key)], " %i", &val[0]);
-                if (res < 1) {
-                    SYNTAX("<offset> (e.g., 0x80) expected.");
-                } else {
-                    d->acsSplitOfs = val[0];
+            }
+          else if (0 == strcmp(key, "split"))
+            {
+              // split %<offset>i
+              res = sscanf(&line[1 + strlen(key)], " %i", &val[0]);
+              if (res < 1)
+                {
+                  SYNTAX("<offset> (e.g., 0x80) expected.");
+                }
+              else
+                {
+                  d->acsSplitOfs = val[0];
                 } // if
-            } else if (0 == strcmp(key, "configrange")) {
-                // configrange %<first>i %<last>i
-                res = sscanf(&line[1+strlen(key)], " %i %i",
-                        &val[0], &val[1]);
-                if (res < 2) {
-                    SYNTAX("<first> <last> (e.g., 0xf60 0xfff) expected.");
-                } else {
-                    d->cwInfo.confAddrStart = val[0];
-                    d->cwInfo.confAddrEnd = val[1];
+            }
+          else if (0 == strcmp(key, "configrange"))
+            {
+              // configrange %<first>i %<last>i
+              res = sscanf(&line[1 + strlen(key)], " %i %i",
+                           &val[0], &val[1]);
+              if (res < 2)
+                {
+                  SYNTAX("<first> <last> (e.g., 0xf60 0xfff) expected.");
+                }
+              else
+                {
+                  d->cwInfo.confAddrStart = val[0];
+                  d->cwInfo.confAddrEnd = val[1];
                 } // if
-            } else if (0 == strcmp(key, "configword")) {
-                // configword %<address>i %<mask>i %<value>i
-                res = sscanf(&line[1+strlen(key)], " %i %i %i",
-                        &val[0], &val[1], &val[2]);
-                if (res < 3) {
-                    SYNTAX("<address> <mask> <value> (e.g., 0x200001 0x0f 0x07) expected.");
-                } else {
-                    val[0] -= d->cwInfo.confAddrStart;
-                    if ((val[0] < 0)
-                            || (val[0] > (d->cwInfo.confAddrEnd - d->cwInfo.confAddrStart))
-                            || (val[0] >= CONFIGURATION_WORDS))
+            }
+          else if (0 == strcmp(key, "configword"))
+            {
+              // configword %<address>i %<mask>i %<value>i [%<and-mask>i]
+              res = sscanf(&line[1 + strlen(key)], " %i %i %i %i",
+                           &val[0], &val[1], &val[2], &val[3]);
+              if (res < 3)
+                {
+                  SYNTAX("<address> <mask> <value> [<and-mask>] (e.g., 0x200001 0x0f 0x07) expected.");
+                }
+              else
+                {
+                  val[0] -= d->cwInfo.confAddrStart;
+                  if ((val[0] < 0)
+                      || (val[0] > (d->cwInfo.confAddrEnd - d->cwInfo.confAddrStart))
+                      || (val[0] >= CONFIGURATION_WORDS))
                     {
-                        SYNTAX("address out of bounds.");
-                    } else {
-                        d->cwInfo.crInfo[val[0]].mask = val[1];
-                        d->cwInfo.crInfo[val[0]].value = val[2];
+                      SYNTAX("address out of bounds.");
+                    }
+                  else
+                    {
+                      d->cwInfo.crInfo[val[0]].mask = val[1];
+                      d->cwInfo.crInfo[val[0]].value = val[2];
+                      d->cwInfo.crInfo[val[0]].andmask = 0;
+                      if (res >= 4)
+                        {
+                          // apply extra mask (e.g., to disable XINST)
+                          d->cwInfo.crInfo[val[0]].andmask = val[3];
+                        } // if
                     } // if
                 } // if
-            } else if (0 == strcmp(key, "idlocrange")) {
-                // idlocrange %<first>i %<last>i
-                res = sscanf(&line[1+strlen(key)], " %i %i",
-                        &val[0], &val[1]);
-                if (res < 2) {
-                    SYNTAX("<first> <last> (e.g., 0xf60 0xfff) expected.");
-                } else {
-                    d->idInfo.idAddrStart = val[0];
-                    d->idInfo.idAddrEnd = val[1];
+            }
+          else if (0 == strcmp(key, "idlocrange"))
+            {
+              // idlocrange %<first>i %<last>i
+              res = sscanf(&line[1 + strlen(key)], " %i %i",
+                           &val[0], &val[1]);
+              if (res < 2)
+                {
+                  SYNTAX("<first> <last> (e.g., 0xf60 0xfff) expected.");
+                }
+              else
+                {
+                  d->idInfo.idAddrStart = val[0];
+                  d->idInfo.idAddrEnd = val[1];
                 } // if
-            } else if (0 == strcmp(key, "idword")) {
-                // idword %<address>i %<value>i
-                res = sscanf(&line[1+strlen(key)], " %i %i",
-                        &val[0], &val[1]);
-                if (res < 2) {
-                    SYNTAX("<address> <value> (e.g., 0x3fffff 0x00) expected.");
-                } else {
-                    val[0] -= d->idInfo.idAddrStart;
-                    if ((val[0] < 0)
-                            || (val[0] > (d->idInfo.idAddrEnd - d->idInfo.idAddrStart))
-                            || (val[0] >= IDLOCATION_BYTES))
+            }
+          else if (0 == strcmp(key, "idword"))
+            {
+              // idword %<address>i %<value>i
+              res = sscanf(&line[1 + strlen(key)], " %i %i",
+                           &val[0], &val[1]);
+              if (res < 2)
+                {
+                  SYNTAX("<address> <value> (e.g., 0x3fffff 0x00) expected.");
+                }
+              else
+                {
+                  val[0] -= d->idInfo.idAddrStart;
+                  if ((val[0] < 0)
+                      || (val[0] > (d->idInfo.idAddrEnd - d->idInfo.idAddrStart))
+                      || (val[0] >= IDLOCATION_BYTES))
+                    {
+                      SYNTAX("address out of bounds.");
+                    }
+                  else
                     {
-                        SYNTAX("address out of bounds.");
-                    } else {
-                        d->idInfo.irInfo[val[0]].value = val[1];
+                      d->idInfo.irInfo[val[0]].value = val[1];
                     } // if
                 } // if
-            } else {
-                printf("%s: Invalid keyword in %s ignored: %s\n",
-                  __func__, DEVICE_FILE_NAME, key);
+            }
+          else
+            {
+              printf("%s: Invalid keyword in %s ignored: %s\n",
+                     __func__, DEVICE_FILE_NAME, key);
             } // if
         } // while
 
-        if (d) {
-            if (tail) {
-                tail->next = d;
-            } else {
-                head = d;
+      if (d)
+        {
+          if (tail)
+            {
+              tail->next = d;
+            }
+          else
+            {
+              head = d;
             } // if
-            tail = d;
-            d = NULL;
+          tail = d;
+          d = NULL;
         } // if
 
-        devices = head;
+      devices = head;
 
-        fclose(f);
+      fclose(f);
     } // if
 
-    d = find_in_list(name, devices);
-    if (!d) {
-        d = &default_device;
+  d = find_in_list(name, devices);
+  if (!d)
+    {
+      d = &default_device;
     } // if
 
-    return (d);
+  return (d);
 }
 
 /*-----------------------------------------------------------------*
@@ -987,45 +1064,65 @@ void pic16_groupRegistersInSection(set *regset)
  * This routine will assign a value to that address.
  *
  *-----------------------------------------------------------------*/
-void pic16_assignConfigWordValue(int address, unsigned int value)
+void
+pic16_assignConfigWordValue(int address, unsigned int value)
 {
   int i;
 
-        for(i=0;i<pic16->cwInfo.confAddrEnd-pic16->cwInfo.confAddrStart+1;i++) {
-                if((address == pic16->cwInfo.confAddrStart+i)
-                  && (pic16->cwInfo.crInfo[i].mask != -1)
-                  && (pic16->cwInfo.crInfo[i].mask != 0)) {
+  for (i = 0; i < pic16->cwInfo.confAddrEnd - pic16->cwInfo.confAddrStart + 1; i++)
+    {
+      if ((address == pic16->cwInfo.confAddrStart + i)
+          && (pic16->cwInfo.crInfo[i].mask != -1)
+          && (pic16->cwInfo.crInfo[i].mask != 0))
+        {
 
 #if 0
-                        fprintf(stderr, "setting location 0x%X to value 0x%x\tmask: 0x%x\ttest: 0x%x\n",
-                                /*address*/ pic16->cwInfo.confAddrStart+i, (~value)&0xff,
-                                        pic16->cwInfo.crInfo[i].mask,
-                                        (pic16->cwInfo.crInfo[i].mask) & (~value));
+          fprintf(stderr, "setting location 0x%x to value 0x%x, mask: 0x%x, test: 0x%x\n",
+                  pic16->cwInfo.confAddrStart + i,
+                  (~value) & 0xff,
+                  pic16->cwInfo.crInfo[i].mask,
+                  (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;
-                        }
+          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;
+            } // if
 #endif
 
-                        pic16->cwInfo.crInfo[i].value = value;
-                        pic16->cwInfo.crInfo[i].emit = 1;
-                        return;
-                }
-        }
+          pic16->cwInfo.crInfo[i].value = (value & 0xff);
+          if (pic16->cwInfo.crInfo[i].andmask
+              && ((value & 0xff) != (value & 0xff & pic16->cwInfo.crInfo[i].andmask)))
+            {
+              // apply andmask if effective
+              printf ("INFO: changing configuration word at 0x%x from 0x%x to 0x%x due to %s\n",
+                      address,
+                      (value & 0xff),
+                      (value & 0xff & pic16->cwInfo.crInfo[i].andmask),
+                      DEVICE_FILE_NAME);
+              pic16->cwInfo.crInfo[i].value &= pic16->cwInfo.crInfo[i].andmask;
+            } // if
+          pic16->cwInfo.crInfo[i].emit = 1;
+          return;
+        } // if
+    } // for
 }
 
-void pic16_assignIdByteValue(int address, char value)
+void
+pic16_assignIdByteValue(int address, char value)
 {
   int i;
 
-        for(i=0;i<pic16->idInfo.idAddrEnd-pic16->idInfo.idAddrStart+1;i++) {
-                if(address == pic16->idInfo.idAddrStart+i) {
-                        pic16->idInfo.irInfo[i].value = value;
-                        pic16->idInfo.irInfo[i].emit = 1;
-                }
-        }
+  for (i = 0; i < pic16->idInfo.idAddrEnd - pic16->idInfo.idAddrStart + 1; i++)
+    {
+      if (address == pic16->idInfo.idAddrStart + i)
+        {
+          pic16->idInfo.irInfo[i].value = value;
+          pic16->idInfo.irInfo[i].emit = 1;
+        } // if
+    } // for
 }
+
index c3dbd623b848f0a36713ca2bd160608aba197528..40361ea0bb281d634d06856c004715011bd7a6df 100644 (file)
 #ifndef  __DEVICE_H__
 #define  __DEVICE_H__
 
-#define CONFIGURATION_WORDS    20
-#define IDLOCATION_BYTES       20
+#define CONFIGURATION_WORDS     20
+#define IDLOCATION_BYTES        20
 
 typedef struct {
-       unsigned int mask;
-       int emit;
-       unsigned int value;
+  unsigned int mask;
+  int emit;
+  unsigned int value;
+  unsigned int andmask;
 } configRegInfo_t;
 
 typedef struct {
-       int confAddrStart;      /* starting address */
-       int confAddrEnd;        /* ending address */
-       configRegInfo_t crInfo[ CONFIGURATION_WORDS ];
+  int confAddrStart;      /* starting address */
+  int confAddrEnd;        /* ending address */
+  configRegInfo_t crInfo[ CONFIGURATION_WORDS ];
 } configWordsInfo_t;
 
 typedef struct {
-       unsigned char emit;
-       unsigned char value;
+  unsigned char emit;
+  unsigned char value;
 } idRegInfo_t;
 
 typedef struct {
-       int idAddrStart;        /* starting ID address */
-       int idAddrEnd;          /* ending ID address */
-       idRegInfo_t irInfo[ IDLOCATION_BYTES ];
+  int idAddrStart;        /* starting ID address */
+  int idAddrEnd;          /* ending ID address */
+  idRegInfo_t irInfo[ IDLOCATION_BYTES ];
 } idBytesInfo_t;
 
 
@@ -62,10 +63,10 @@ typedef struct {
 typedef struct PIC16_device {
   char *name[PROCESSOR_NAMES];  /* aliases for the processor name */
   /* RAMsize *must* be the first item to copy for 'using' */
-  int RAMsize;                 /* size of Data RAM - VR 031120 */
-  int acsSplitOfs;             /* access bank split offset */
-  configWordsInfo_t cwInfo;    /* configuration words info */
-  idBytesInfo_t idInfo;                /* ID Locations info */
+  int RAMsize;                  /* size of Data RAM - VR 031120 */
+  int acsSplitOfs;              /* access bank split offset */
+  configWordsInfo_t cwInfo;     /* configuration words info */
+  idBytesInfo_t idInfo;         /* ID Locations info */
   /* next *must* be the first field NOT being copied via 'using' */
   struct PIC16_device *next;    /* linked list */
 } PIC16_device;
@@ -75,10 +76,10 @@ extern PIC16_device *pic16;
 /* Given a pointer to a register, this macro returns the bank that it is in */
 #define REG_ADDR(r)        ((r)->isBitField ? (((r)->address)>>3) : (r)->address)
 
-#define OF_LR_SUPPORT          0x00000001
-#define OF_NO_OPTIMIZE_GOTO    0x00000002
-#define OF_OPTIMIZE_CMP                0x00000004
-#define OF_OPTIMIZE_DF         0x00000008
+#define OF_LR_SUPPORT           0x00000001
+#define OF_NO_OPTIMIZE_GOTO     0x00000002
+#define OF_OPTIMIZE_CMP         0x00000004
+#define OF_OPTIMIZE_DF          0x00000008
 
 typedef struct {
   int no_banksel;
@@ -101,8 +102,8 @@ typedef struct {
 
 extern pic16_options_t pic16_options;
 
-#define STACK_MODEL_SMALL      (pic16_options.stack_model == 0)
-#define STACK_MODEL_LARGE      (pic16_options.stack_model == 1)
+#define STACK_MODEL_SMALL       (pic16_options.stack_model == 0)
+#define STACK_MODEL_LARGE       (pic16_options.stack_model == 1)
 
 extern set *fix_idataSymSet;
 extern set *rel_idataSymSet;