* src/SDCCval.c, src/SDCCval.h:
authorborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 9 Feb 2008 16:45:05 +0000 (16:45 +0000)
committerborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 9 Feb 2008 16:45:05 +0000 (16:45 +0000)
  code cleaning, added function constChrVal()
* src/SDCCglue.c, src/pic/glue.c, src/pic16/glue.c, src/SDCCast.c, src/SDCC.y:
  call constChrVal() instead constVal()

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

ChangeLog
src/SDCC.y
src/SDCCast.c
src/SDCCglue.c
src/SDCCval.c
src/SDCCval.h
src/pic/glue.c
src/pic16/glue.c

index 077819c0ebdb79a21a2e339715e2124cc2590b61..a2e75c5e8fa6b2bf2d96cd25669e081786d87e0d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-02-09 Borut Razem <borut.razem AT siol.net>
+
+       * src/SDCCval.c, src/SDCCval.h:
+         code cleaning, added function constChrVal()
+       * src/SDCCglue.c, src/pic/glue.c, src/pic16/glue.c, src/SDCCast.c, src/SDCC.y:
+         call constChrVal() instead constVal()
+
 2008-02-01 Maarten Brock <sourceforge.brock AT dse.nl>
 
        * src/SDCCast.c (resolveSymbols): added reentrancy check for parameters
index 782d58325703212fae2be7d69fb9865805d1f405..b37f2ba868bd945422e482d169402cf1cbe99b67 100644 (file)
@@ -521,7 +521,7 @@ declaration_specifiers
        $$ = mergeSpec($1,$2, "type_specifier declaration_specifiers");
    }
    | function_specifier                             { $$ = $1; }
-   | function_specifier declaration_specifiers          { 
+   | function_specifier declaration_specifiers          {
      /* if the decl $2 is not a specifier */
      /* find the spec and replace it      */
      if ( !IS_SPEC($2)) {
@@ -1040,7 +1040,7 @@ opt_assign_expr
                                  $$ = cenum = constVal(lbuff);
                               }
                               else {
-                                 $$ = cenum = constVal("0");
+                                 $$ = cenum = constCharVal(0);
                               }
                            }
    ;
@@ -1203,7 +1203,7 @@ pointer
          }
    | unqualified_pointer type_specifier_list pointer
          {
-             $$ = $1 ;               
+             $$ = $1 ;
              if (IS_SPEC($2) && DCL_TYPE($3) == UPOINTER) {
                  DCL_PTR_CONST($1) = SPEC_CONST($2);
                  DCL_PTR_VOLATILE($1) = SPEC_VOLATILE($2);
@@ -1228,12 +1228,12 @@ pointer
                      DCL_TYPE($3) = EEPPOINTER;
                      break;
                  default:
-                   // this could be just "constant" 
+                   // this could be just "constant"
                    // werror(W_PTR_TYPE_INVALID);
                      ;
                  }
              }
-             else 
+             else
                  werror (W_PTR_TYPE_INVALID);
              $$->next = $3 ;
          }
index 97581fee14dd9027cef9b8f717dc3f4eef0d7aae..60f5a1d2ea3daf1c514abfb7500da30e8cbd3c21 100644 (file)
@@ -1651,7 +1651,7 @@ isLoopCountable (ast * initExpr, ast * condExpr, ast * loopExpr,
             {
 
               *end = newNode ('+', condExpr->left->right,
-                              newAst_VALUE (constVal ("1")));
+                              newAst_VALUE (constCharVal (1)));
               break;
             }
           return FALSE;
@@ -2072,7 +2072,7 @@ replLoopSym (ast * body, symbol * sym)
           body->type = EX_OP;
           body->opval.op = '-';
           body->left = newAst_VALUE (symbolVal (sym));
-          body->right = newAst_VALUE (constVal ("1"));
+          body->right = newAst_VALUE (constCharVal (1));
 
         }
 
@@ -2124,7 +2124,7 @@ reverseLoop (ast * loop, symbol * sym, ast * init, ast * end)
                                          newNode (NULLOP,
                                                   newNode (SUB_ASSIGN,
                                                            newAst_VALUE (symbolVal (sym)),
-                                                           newAst_VALUE (constVal ("1"))),
+                                                           newAst_VALUE (constCharVal (1))),
                                                   rloop))));
 
   rloop->lineno=init->lineno;
@@ -3131,7 +3131,7 @@ decorateType (ast * tree, RESULT_TYPE resultType)
                                             copyAst (tree->right));
                   litTree->right->lineno = tree->lineno;
 
-                  tree->right->opval.val = constVal ("1");
+                  tree->right->opval.val = constCharVal (1);
                   decorateType (parent, resultType);
                 }
               else
@@ -3525,7 +3525,7 @@ decorateType (ast * tree, RESULT_TYPE resultType)
         {
           tree->type = EX_VALUE;
           tree->left = tree->right = NULL;
-          tree->opval.val = constVal ("0");
+          tree->opval.val = constCharVal (0);
           TETYPE (tree) = TTYPE (tree) = tree->opval.val->type;
           return tree;
         }
@@ -3640,7 +3640,7 @@ decorateType (ast * tree, RESULT_TYPE resultType)
 
           /* optimize bit-result, even if we optimize a buggy source */
           tree->type = EX_VALUE;
-          tree->opval.val = constVal ("1");
+          tree->opval.val = constCharVal (1);
         }
       else
         tree->left = addCast (tree->left, resultTypeProp, TRUE);
@@ -3674,8 +3674,8 @@ decorateType (ast * tree, RESULT_TYPE resultType)
           tree->opval.op = '?';
           tree->left  = tree->left->left;
           tree->right = newNode (':',
-                                  newAst_VALUE (constVal ("1")),
-                                  newAst_VALUE (constVal ("0")));
+                                  newAst_VALUE (constCharVal (1)),
+                                  newAst_VALUE (constCharVal (0)));
           tree->right->lineno = tree->lineno;
           tree->decorated = 0;
           return decorateType (tree, resultType);
@@ -3797,7 +3797,7 @@ decorateType (ast * tree, RESULT_TYPE resultType)
                       (tree->opval.op == LEFT_OP ? "left" : "right"));
               tree->type = EX_VALUE;
               tree->left = tree->right = NULL;
-              tree->opval.val = constVal ("0");
+              tree->opval.val = constCharVal (0);
               TETYPE (tree) = TTYPE (tree) = tree->opval.val->type;
               return tree;
             }
@@ -4139,8 +4139,8 @@ decorateType (ast * tree, RESULT_TYPE resultType)
                 if (!options.lessPedantic)
                   werrorfl (tree->filename, tree->lineno, W_COMP_RANGE,
                           ccr_result == CCR_ALWAYS_TRUE ? "true" : "false");
-                return decorateType (newAst_VALUE (constVal (
-                                   ccr_result == CCR_ALWAYS_TRUE ? "1" : "0")),
+                return decorateType (newAst_VALUE (constCharVal (
+                                   ccr_result == CCR_ALWAYS_TRUE ? 1 : 0)),
                                                    resultType);
               case CCR_OK:
               default:
@@ -4164,7 +4164,7 @@ decorateType (ast * tree, RESULT_TYPE resultType)
           /* (unsigned value) ? 1 : 0 */
           tree->opval.op = '?';
           tree->right = newNode (':',
-                                  newAst_VALUE (constVal ("1")),
+                                  newAst_VALUE (constCharVal (1)),
                                   tree->right); /* val 0 */
           tree->right->lineno = tree->lineno;
           tree->right->left->lineno = tree->lineno;
@@ -5795,12 +5795,12 @@ optimizeCompare (ast * root)
         case '>':
         case '<':
         case NE_OP:
-          optExpr = newAst_VALUE (constVal ("0"));
+          optExpr = newAst_VALUE (constCharVal (0));
           break;
         case GE_OP:
         case LE_OP:
         case EQ_OP:
-          optExpr = newAst_VALUE (constVal ("1"));
+          optExpr = newAst_VALUE (constCharVal (1));
           break;
         }
 
@@ -5950,7 +5950,7 @@ static void
 fixupInlineLabel (symbol * sym)
 {
   char name[SDCC_NAME_MAX + 1];
-  
+
   SNPRINTF(name, sizeof(name), "%s_%d", sym->name, inlineState.count);
   strcpy (sym->name, name);
 }
@@ -5968,7 +5968,7 @@ copyAstLoc (ast * dest, ast * src)
   dest->level = src->level;
   dest->block = src->block;
   dest->seqPoint = src->seqPoint;
-  
+
 }
 
 
index c05896df5a0e7b88cbbe22737f0be19fc33b4709..9aa05c9c0e0fb267388554616a0467332f5d4f1c 100644 (file)
@@ -110,7 +110,7 @@ aopLiteralLong (value * val, int offset, int size)
 
   if (!val) {
     // assuming we have been warned before
-    val=constVal("0");
+    val = constCharVal (0);
   }
 
   /* if it is a float then it gets tricky */
@@ -630,7 +630,7 @@ printIvalType (symbol *sym, sym_link * type, initList * ilist, struct dbuf_s * o
 
   if (!(val = list2val (ilist))) {
     // assuming a warning has been thrown
-    val=constVal("0");
+    val = constCharVal (0);
   }
 
   if (val->type != type) {
@@ -881,7 +881,7 @@ printIvalFuncPtr (sym_link * type, initList * ilist, struct dbuf_s * oBuf)
 
   if (!val) {
     // an error has been thrown already
-    val=constVal("0");
+    val = constCharVal (0);
   }
 
   if (IS_LITERAL(val->etype)) {
index 2dcd2b4ac4ad31632e932c01161909cfeabdea75..88fa5470d8b09f3bc3a55ec53689e2e76f7d2f7e 100644 (file)
@@ -36,7 +36,7 @@ int cNestLevel;
 /* newValue - allocates and returns a new value        */
 /*-----------------------------------------------------------------*/
 value *
-newValue ()
+newValue (void)
 {
   value *val;
 
@@ -639,7 +639,7 @@ valueFromLit (double lit)
 /* constFloatVal - converts a FLOAT constant to value              */
 /*-----------------------------------------------------------------*/
 value *
-constFloatVal (char *s)
+constFloatVal (const char *s)
 {
   value *val = newValue ();
   double sval;
@@ -649,7 +649,7 @@ constFloatVal (char *s)
   if (p == s)
     {
       werror (E_INVALID_FLOAT_CONST, s);
-      return constVal ("0");
+      return constCharVal (0);
     }
 
   val->type = val->etype = newLink (SPECIFIER);
@@ -664,7 +664,7 @@ constFloatVal (char *s)
 /* constFixed16x16Val - converts a FIXED16X16 constant to value    */
 /*-----------------------------------------------------------------*/
 value *
-constFixed16x16Val (char *s)
+constFixed16x16Val (const char *s)
 {
   value *val = newValue ();
   double sval;
@@ -674,7 +674,7 @@ constFixed16x16Val (char *s)
   if (p == s)
     {
       werror (E_INVALID_FLOAT_CONST, s);
-      return constVal ("0");
+      return constCharVal (0);
     }
 
   val->type = val->etype = newLink (SPECIFIER);
@@ -691,7 +691,8 @@ constFixed16x16Val (char *s)
 value *constVal (const char *s)
 {
   value *val;
-  short hex = 0, octal = 0;
+  bool hex = FALSE, octal = FALSE;
+  char *p;
   double dval;
 
   val = newValue ();            /* alloc space for value   */
@@ -702,84 +703,108 @@ value *constVal (const char *s)
   SPEC_NOUN (val->type) = V_CHAR;
   SPEC_USIGN (val->type) = 0;
 
-  hex = ((strchr (s, 'x') || strchr (s, 'X')) ? 1 : 0);
-
-  /* set the octal flag   */
-  if (!hex && *s == '0' && *(s + 1))
-    octal = 1;
+  if (s[0] == '0')
+    {
+      if (s[1] == 'x' || s[1] == 'X')
+        hex = TRUE;
+      else if (isdigit(s[1]))
+        octal = TRUE;
+    }
 
   errno = 0;
-  if (hex || octal) {
-    unsigned long sval;
-    sval = strtoul (s, NULL, 0);
-    dval = sval;
-    if (errno) {
-      dval = 4294967295.0;
-      werror (W_INVALID_INT_CONST, s, dval);
+  if (hex || octal)
+    {
+      dval = strtoul (s, &p, 0);
+      if (errno)
+        {
+          dval = 4294967295.0;
+          werror (W_INVALID_INT_CONST, s, dval);
+        }
+    }
+  else
+    {
+      dval = strtod(s, &p);
     }
-  } else {
-    dval = strtod(s, NULL);
-  }
 
   /* Setup the flags first */
   /* set the unsigned flag if 'uU' is found */
-  if (strchr (s, 'u') || strchr (s, 'U')) {
-    SPEC_USIGN (val->type) = 1;
-  }
+  if (strchr (p, 'u') || strchr (p, 'U'))
+    {
+      SPEC_USIGN (val->type) = 1;
+    }
 
   /* set the b_long flag if 'lL' is found */
-  if (strchr (s, 'l') || strchr (s, 'L')) {
-    SPEC_NOUN (val->type) = V_INT;
-    SPEC_LONG (val->type) = 1;
-  } else {
-    if (dval<0) { /* "-28u" will still be signed and negative */
-      if (dval<-128) { /* check if we have to promote to int */
-        SPEC_NOUN (val->type) = V_INT;
-      }
-      if (dval<-32768) { /* check if we have to promote to long int */
-        SPEC_LONG (val->type) = 1;
-      }
-    } else { /* >=0 */
-      if (dval>0xff ||  /* check if we have to promote to int */
-          SPEC_USIGN (val->type)) { /* if it's unsigned, we can't use unsigned
-                                     char. After an integral promotion it will
-                                     be a signed int; this certainly isn't what
-                                     the programer wants */
-        SPEC_NOUN (val->type) = V_INT;
-      }
-      else { /* store char's always as unsigned; this helps other optimizations */
-        SPEC_USIGN (val->type) = 1;
-      }
-      if (dval>0xffff && SPEC_USIGN (val->type)) { /* check if we have to promote to long */
-        SPEC_LONG (val->type) = 1;
-      }
-      else if (dval>0x7fff && !SPEC_USIGN (val->type)) { /* check if we have to promote to long int */
-        if ((hex || octal) && /* hex or octal constants may be stored in unsigned type */
-            dval<=0xffff) {
-          SPEC_USIGN (val->type) = 1;
-        } else {
-          SPEC_LONG (val->type) = 1;
-          if (dval>0x7fffffff) {
-            SPEC_USIGN (val->type) = 1;
-          }
+  if (strchr (p, 'l') || strchr (p, 'L'))
+    {
+      SPEC_NOUN (val->type) = V_INT;
+      SPEC_LONG (val->type) = 1;
+    }
+  else
+    {
+      if (dval < 0)
+        { /* "-28u" will still be signed and negative */
+          if (dval < -128)
+            { /* check if we have to promote to int */
+              SPEC_NOUN (val->type) = V_INT;
+            }
+          if (dval < -32768)
+            { /* check if we have to promote to long int */
+              SPEC_LONG (val->type) = 1;
+            }
+        }
+      else
+        { /* >=0 */
+          if (dval > 0xff ||  /* check if we have to promote to int */
+            SPEC_USIGN (val->type))
+            { /* if it's unsigned, we can't use unsigned
+                 char. After an integral promotion it will
+                 be a signed int; this certainly isn't what
+                 the programer wants */
+              SPEC_NOUN (val->type) = V_INT;
+            }
+          else
+            { /* store char's always as unsigned; this helps other optimizations */
+              SPEC_USIGN (val->type) = 1;
+            }
+          if (dval > 0xffff && SPEC_USIGN (val->type))
+            { /* check if we have to promote to long */
+              SPEC_LONG (val->type) = 1;
+            }
+          else if (dval > 0x7fff && !SPEC_USIGN (val->type))
+            { /* check if we have to promote to long int */
+              if ((hex || octal) && /* hex or octal constants may be stored in unsigned type */
+                dval <= 0xffff)
+                {
+                  SPEC_USIGN (val->type) = 1;
+                }
+              else
+                {
+                  SPEC_LONG (val->type) = 1;
+                  if (dval > 0x7fffffff)
+                    {
+                      SPEC_USIGN (val->type) = 1;
+                    }
+                }
+            }
         }
-      }
     }
-  }
 
   /* check for out of range */
-  if (dval<-2147483648.0) {
-    dval = -2147483648.0;
-    werror (W_INVALID_INT_CONST, s, dval);
-  }
-  if (dval>2147483647.0 && !SPEC_USIGN (val->type)) {
-    dval = 2147483647.0;
-    werror (W_INVALID_INT_CONST, s, dval);
-  }
-  if (dval>4294967295.0) {
-    dval = 4294967295.0;
-    werror (W_INVALID_INT_CONST, s, dval);
-  }
+  if (dval < -2147483648.0)
+    {
+      dval = -2147483648.0;
+      werror (W_INVALID_INT_CONST, s, dval);
+    }
+  if (dval > 2147483647.0 && !SPEC_USIGN (val->type))
+    {
+      dval = 2147483647.0;
+      werror (W_INVALID_INT_CONST, s, dval);
+    }
+  if (dval > 4294967295.0)
+    {
+      dval = 4294967295.0;
+      werror (W_INVALID_INT_CONST, s, dval);
+    }
 
   if (SPEC_LONG (val->type))
     {
@@ -807,6 +832,20 @@ value *constVal (const char *s)
   return val;
 }
 
+value *constCharVal (unsigned char v)
+{
+  value *val = newValue ();            /* alloc space for value   */
+
+  val->type = val->etype = newLink (SPECIFIER); /* create the specifier */
+  SPEC_SCLS (val->type) = S_LITERAL;
+  /* let's start with a signed char */
+  SPEC_NOUN (val->type) = V_CHAR;
+  SPEC_USIGN (val->type) = 1;
+  SPEC_CVAL (val->type).v_uint = v;
+
+  return val;
+}
+
 /*------------------------------------------------------------------*/
 /* strVal - converts a string constant to a value                   */
 /*------------------------------------------------------------------*/
@@ -923,55 +962,34 @@ copyValue (value * src)
 value *
 charVal (const char *s)
 {
-  value *val;
-
-  val = newValue ();
-
-  val->type = val->etype = newLink (SPECIFIER);
-  SPEC_NOUN (val->type) = V_CHAR;
-  SPEC_USIGN(val->type) = 1;
-  SPEC_SCLS (val->type) = S_LITERAL;
-
-  s++;                          /* get rid of quotation */
+  /* get rid of quotation */
   /* if \ then special processing */
-  if (*s == '\\')
+  if (*++s == '\\')
     {
-      s++;                      /* go beyond the backslash  */
-      switch (*s)
+      switch (*++s)             /* go beyond the backslash  */
         {
         case 'n':
-          SPEC_CVAL (val->type).v_uint = '\n';
-          break;
+          return constCharVal ('\n');
         case 't':
-          SPEC_CVAL (val->type).v_uint = '\t';
-          break;
+          return constCharVal ('\t');
         case 'v':
-          SPEC_CVAL (val->type).v_uint = '\v';
-          break;
+          return constCharVal ('\v');
         case 'b':
-          SPEC_CVAL (val->type).v_uint = '\b';
-          break;
+          return constCharVal ('\b');
         case 'r':
-          SPEC_CVAL (val->type).v_uint = '\r';
-          break;
+          return constCharVal ('\r');
         case 'f':
-          SPEC_CVAL (val->type).v_uint = '\f';
-          break;
+          return constCharVal ('\f');
         case 'a':
-          SPEC_CVAL (val->type).v_uint = '\a';
-          break;
+          return constCharVal ('\a');
         case '\\':
-          SPEC_CVAL (val->type).v_uint = '\\';
-          break;
+          return constCharVal ('\\');
         case '\?':
-          SPEC_CVAL (val->type).v_uint = '\?';
-          break;
+          return constCharVal ('\?');
         case '\'':
-          SPEC_CVAL (val->type).v_uint = '\'';
-          break;
+          return constCharVal ('\'');
         case '\"':
-          SPEC_CVAL (val->type).v_uint = '\"';
-          break;
+          return constCharVal ('\"');
 
         case '0' :
         case '1' :
@@ -981,22 +999,17 @@ charVal (const char *s)
         case '5' :
         case '6' :
         case '7' :
-          SPEC_CVAL (val->type).v_uint = octalEscape(&s);
-          break;
+          return constCharVal (octalEscape (&s));
 
         case 'x':
-          SPEC_CVAL (val->type).v_uint = hexEscape(&s) ;
-          break;
+          return constCharVal (hexEscape (&s));
 
         default:
-          SPEC_CVAL (val->type).v_uint = (unsigned char)*s;
-          break;
+           return constCharVal (*s);
         }
     }
   else                          /* not a backslash */
-    SPEC_CVAL (val->type).v_uint = (unsigned char)*s;
-
-  return val;
+    return constCharVal (*s);
 }
 
 /*------------------------------------------------------------------*/
@@ -1143,14 +1156,14 @@ double doubleFromFixed16x16(TYPE_TARGET_ULONG value)
   double tmp=0, exp=2;
 
     tmp = (value & 0xffff0000) >> 16;
-    
+
     while(value) {
       value &= 0xffff;
       if(value & 0x8000)tmp += 1/exp;
       exp *= 2;
       value <<= 1;
     }
-  
+
   return (tmp);
 #else
   return ((double)(value * 1.0) / (double)(1UL << 16));
@@ -1167,14 +1180,14 @@ TYPE_TARGET_ULONG fixed16x16FromDouble(double value)
     tmp = floor( value );
     res = tmp << 16;
     value -= tmp;
-    
+
     tmp = 0;
     while(pos--) {
       value *= 2;
       if(value >= 1.0)tmp |= (1 << pos);
       value -= floor( value );
     }
-  
+
     res |= tmp;
 
   return (res);
index 98a1a7eb8b33df29db4c895324da058857545104..03b7dd138a1dfa8f05166678d9c222c4178795ee 100644 (file)
@@ -18,7 +18,7 @@
 
   In other words, you are welcome to use, share and improve this program.
   You are forbidden to forbid anyone else to use, share and improve
-  what you give them.   Help stamp out software-hoarding!  
+  what you give them.   Help stamp out software-hoarding!
 -------------------------------------------------------------------------*/
 #ifndef SDCCVAL_H
 #define SDCCVAL_H
@@ -95,9 +95,9 @@ CCR_RESULT;
 #define  IS_VARG(x)             (x->vArgs)
 
 /* forward definitions for the symbol table related functions */
-void initValue ();
-value *newValue ();
+value *newValue (void);
 value *constVal (const char *);
+value *constCharVal (unsigned char);
 value *reverseVal (value *);
 value *reverseValWithType (value *);
 value *copyValue (value *);
@@ -139,8 +139,8 @@ value *list2val (initList *);
 struct ast *list2expr (initList *);
 void resolveIvalSym (initList *, sym_link *);
 value *valFromType (sym_link *);
-value *constFloatVal (char *);
-value *constFixed16x16Val (char *);
+value *constFloatVal (const char *);
+value *constFixed16x16Val (const char *);
 int getNelements (sym_link *, initList *);
 value *valForArray (struct ast *);
 value *valForStructElem (struct ast *, struct ast *);
index f912ec7f50d741cdd4a3e6270cacd3d11aab0704..1ba22eee9fa9bdec2cd3c24769836239402ab860 100644 (file)
@@ -92,15 +92,15 @@ unsigned int pic14aopLiteral (value *val, int offset)
                 float f;
                 unsigned char c[4];
         } fl;
-        
+
         /* if it is a float then it gets tricky */
         /* otherwise it is fairly simple */
         if (!IS_FLOAT(val->type)) {
                 unsigned long v = ulFromVal (val);
-                
+
                 return ( (v >> (offset * 8)) & 0xff);
         }
-        
+
         /* it is type float */
         fl.f = (float) floatFromVal(val);
 #ifdef WORDS_BIGENDIAN
@@ -108,7 +108,7 @@ unsigned int pic14aopLiteral (value *val, int offset)
 #else
         return fl.c[offset];
 #endif
-        
+
 }
 
 #if 0
@@ -118,7 +118,7 @@ is_valid_identifier( const char *name )
   char a;
   if (!name) return 0;
   a = *name;
-  
+
   /* only accept [a-zA-Z_][a-zA-Z0-9_] */
   if (!((a >= 'a' && a <= 'z')
         || (a >= 'A' && a <= 'z')
@@ -244,7 +244,7 @@ pic14_constructAbsMap (struct dbuf_s *oBuf, struct dbuf_s *gloBuf)
           }
           continue;
         }
-        
+
         if (max == -1 || addr > max) max = addr;
         if (min == -1 || addr < min) min = addr;
         //fprintf (stderr, "%s: sym %s @ 0x%x\n", __FUNCTION__, sym->name, addr);
@@ -279,7 +279,7 @@ pic14_constructAbsMap (struct dbuf_s *oBuf, struct dbuf_s *gloBuf)
           if (sym->ival) break;
       } // for
       if (sym) continue;
-      
+
       dbuf_printf (oBuf, "UD_abs_%s_%x\tudata_ovr\t0x%04x\n",
           moduleName, addr, addr);
       for (sym = setFirstItem (aliases); sym;
@@ -288,10 +288,10 @@ pic14_constructAbsMap (struct dbuf_s *oBuf, struct dbuf_s *gloBuf)
         if (getSize(sym->type) > size) {
           size = getSize(sym->type);
         }
-        
+
         /* initialized values are handled somewhere else */
         if (sym->ival) continue;
-        
+
         /* emit STATUS as well as _STATUS, required for SFRs only */
         //dbuf_printf (oBuf, "%s\tres\t0\n", sym->name);
         dbuf_printf (oBuf, "%s\n", sym->rname);
@@ -315,27 +315,27 @@ pic14emitRegularMap (memmap * map, bool addPublics, bool arFlag)
 {
         symbol *sym;
         int bitvars = 0;;
-        
+
         /* print the area name */
         if (addPublics)
                 dbuf_printf (&map->oBuf, ";\t.area\t%s\n", map->sname);
-        
+
         for (sym = setFirstItem (map->syms); sym;
         sym = setNextItem (map->syms)) {
-                
+
                 //printf("%s\n",sym->name);
 
                 /* ignore if config word */
                 if (SPEC_ABSA(sym->etype)
                     && IS_CONFIG_ADDRESS(SPEC_ADDR(sym->etype)))
                         continue;
-                
+
                 /* if extern then add it into the extern list */
                 if (IS_EXTERN (sym->etype)) {
                         addSetHead (&externs, sym);
                         continue;
                 }
-                
+
                 /* if allocation required check is needed
                 then check if the symbol really requires
                 allocation only for local variables */
@@ -343,7 +343,7 @@ pic14emitRegularMap (memmap * map, bool addPublics, bool arFlag)
                         !(sym->_isparm && !IS_REGPARM (sym->etype)) &&
                         !sym->allocreq && sym->level)
                         continue;
-                
+
                 /* if global variable & not static or extern
                 and addPublics allowed then add it to the public set */
                 if ((sym->level == 0 ||
@@ -354,7 +354,7 @@ pic14emitRegularMap (memmap * map, bool addPublics, bool arFlag)
                         //fprintf( stderr, "%s: made public %s\n", __FUNCTION__, sym->name );
                         addSetHead (&publics, sym);
                 }
-                
+
                 // PIC code allocates its own registers - so ignore parameter variable generated by processFuncArgs()
                 if (sym->_isparm)
                         continue;
@@ -380,14 +380,14 @@ pic14emitRegularMap (memmap * map, bool addPublics, bool arFlag)
                 /* absolute symbols are handled in pic14_constructAbsMap */
                 if (SPEC_ABSA(sym->etype) && IS_DEFINED_HERE(sym))
                         continue;
-                
+
                 /* if it has an absolute address then generate
                 an equate for this no need to allocate space */
                 if (0 && SPEC_ABSA (sym->etype))
                 {
                         //if (options.debug || sym->level == 0)
                         //dbuf_printf (&map->oBuf,"; == 0x%04x\n",SPEC_ADDR (sym->etype));
-                        
+
                         dbuf_printf (&map->oBuf, "%s\tEQU\t0x%04x\n",
                                 sym->rname,
                                 SPEC_ADDR (sym->etype));
@@ -395,7 +395,7 @@ pic14emitRegularMap (memmap * map, bool addPublics, bool arFlag)
                 else
                 {
                         /* allocate space */
-                        
+
                         /* If this is a bit variable, then allocate storage after 8 bits have been declared */
                         /* unlike the 8051, the pic does not have a separate bit area. So we emulate bit ram */
                         /* by grouping the bits together into groups of 8 and storing them in the normal ram. */
@@ -407,7 +407,7 @@ pic14emitRegularMap (memmap * map, bool addPublics, bool arFlag)
                         {
                             if (!sym->ival) {
                                 emitSymbol (&map->oBuf,
-                                        sym->rname, 
+                                        sym->rname,
                                         NULL,
                                         getSize (sym->type) & 0xffff,
                                         SPEC_ABSA(sym->etype)
@@ -419,7 +419,7 @@ pic14emitRegularMap (memmap * map, bool addPublics, bool arFlag)
                                 /*
                                 {
                                 int i, size;
-                                
+
                                   if ((size = (unsigned int) getSize (sym->type) & 0xffff) > 1)
                                   {
                                   for (i = 1; i < size; i++)
@@ -438,12 +438,12 @@ pic14emitRegularMap (memmap * map, bool addPublics, bool arFlag)
                     pic14_stringInSet(sym->name, &emitted, 1);
                     pic14_stringInSet(sym->rname, &emitted, 1);
                 }
-#if 0           
+#if 0
                 /* if it has a initial value then do it only if
                 it is a global variable */
                 if (sym->ival && sym->level == 0) {
                         ast *ival = NULL;
-                
+
                         if (IS_AGGREGATE (sym->type))
                                 ival = initAggregates (sym, sym->ival, NULL);
                         else
@@ -464,46 +464,46 @@ pic14emitRegularMap (memmap * map, bool addPublics, bool arFlag)
 /*-----------------------------------------------------------------*/
 /* printIvalType - generates ival for int/char                     */
 /*-----------------------------------------------------------------*/
-static void 
+static void
 printIvalType (symbol *sym, sym_link * type, initList * ilist, pBlock *pb)
 {
         value *val;
         unsigned long ulval;
-        
+
         //fprintf(stderr, "%s\n",__FUNCTION__);
-        
+
         /* if initList is deep */
         if (ilist->type == INIT_DEEP)
                 ilist = ilist->init.deep;
-        
+
         if (!IS_AGGREGATE(sym->type) && getNelements(type, ilist)>1) {
                 werror (W_EXCESS_INITIALIZERS, "scalar", sym->name, sym->lineDef);
         }
-        
+
         if (!(val = list2val (ilist))) {
                 // assuming a warning has been thrown
-                val=constVal("0");
+                val = constCharVal (0);
         }
-        
+
         if (val->type != type) {
                 val = valCastLiteral(type, floatFromVal(val));
         }
-        
-        if(val) 
+
+        if(val)
                 ulval = ulFromVal (val);
         else
                 ulval =0;
-        
+
         switch (getSize (type)) {
         case 1:
                 addpCode2pBlock(pb,newpCode(POC_RETLW,newpCodeOpLit(BYTE_IN_LONG(ulval,0))));
                 break;
-                
+
         case 2:
                 addpCode2pBlock(pb,newpCode(POC_RETLW,newpCodeOpLit(BYTE_IN_LONG(ulval,0))));
                 addpCode2pBlock(pb,newpCode(POC_RETLW,newpCodeOpLit(BYTE_IN_LONG(ulval,1))));
                 break;
-                
+
         case 4:
                 addpCode2pBlock(pb,newpCode(POC_RETLW,newpCodeOpLit(BYTE_IN_LONG(ulval,0))));
                 addpCode2pBlock(pb,newpCode(POC_RETLW,newpCodeOpLit(BYTE_IN_LONG(ulval,1))));
@@ -516,25 +516,25 @@ printIvalType (symbol *sym, sym_link * type, initList * ilist, pBlock *pb)
 /*-----------------------------------------------------------------*/
 /* printIvalBitFields - generate initializer for bitfields         */
 /*-----------------------------------------------------------------*/
-static void printIvalBitFields(symbol **sym, initList **ilist, pBlock *pb ) 
+static void printIvalBitFields(symbol **sym, initList **ilist, pBlock *pb )
 {
         value *val ;
         symbol *lsym = *sym;
         initList *lilist = *ilist ;
         unsigned long ival = 0;
         int size =0;
-        
-        
+
+
         do {
                 unsigned long i;
                 val = list2val(lilist);
                 if (size) {
                         if (SPEC_BLEN(lsym->etype) > 8) {
-                                size += ((SPEC_BLEN (lsym->etype) / 8) + 
+                                size += ((SPEC_BLEN (lsym->etype) / 8) +
                                         (SPEC_BLEN (lsym->etype) % 8 ? 1 : 0));
                         }
                 } else {
-                        size = ((SPEC_BLEN (lsym->etype) / 8) + 
+                        size = ((SPEC_BLEN (lsym->etype) / 8) +
                                 (SPEC_BLEN (lsym->etype) % 8 ? 1 : 0));
                 }
                 i = ulFromVal (val);
@@ -551,7 +551,7 @@ static void printIvalBitFields(symbol **sym, initList **ilist, pBlock *pb )
                 //tfprintf (oFile, "\t!db !constbyte\n",ival);
                 addpCode2pBlock(pb,newpCode(POC_RETLW,newpCodeOpLit(ival)));
                 break;
-                
+
         case 2:
                 //tfprintf (oFile, "\t!dw !constword\n",ival);
                 addpCode2pBlock(pb,newpCode(POC_RETLW,newpCodeOpLit(ival>>8)));
@@ -576,18 +576,18 @@ static void printIvalStruct (symbol * sym, sym_link * type, initList * ilist, pB
 {
         symbol *sflds;
         initList *iloop = NULL;
-        
+
         sflds = SPEC_STRUCT (type)->fields;
-        
+
         if (ilist) {
                 if (ilist->type != INIT_DEEP) {
                         werrorfl (sym->fileDef, sym->lineDef, E_INIT_STRUCT, sym->name);
                         return;
                 }
-                
+
                 iloop = ilist->init.deep;
         }
-        
+
         for (; sflds; sflds = sflds->next, iloop = (iloop ? iloop->next : NULL)) {
                 if (IS_BITFIELD(sflds->type)) {
                         printIvalBitFields(&sflds,&iloop,pb);
@@ -604,19 +604,19 @@ static void printIvalStruct (symbol * sym, sym_link * type, initList * ilist, pB
 /*-----------------------------------------------------------------*/
 /* printIvalChar - generates initital value for character array    */
 /*-----------------------------------------------------------------*/
-static int 
+static int
 printIvalChar (sym_link * type, initList * ilist, pBlock *pb, char *s)
 {
         value *val;
         int remain, ilen;
-        
+
         if(!pb)
                 return 0;
-        
+
         //fprintf(stderr, "%s\n",__FUNCTION__);
         if (!s)
         {
-                
+
                 val = list2val (ilist);
 
                 /* if the value is a character string  */
@@ -626,12 +626,12 @@ printIvalChar (sym_link * type, initList * ilist, pBlock *pb, char *s)
 
                         if (!DCL_ELEM (type))
                                 DCL_ELEM (type) = ilen;
-                
+
                         /* emit string constant */
                         for (remain = 0; remain < ilen; remain++) {
                                 addpCode2pBlock(pb,newpCode(POC_RETLW,newpCodeOpLit(SPEC_CVAL(val->etype).v_char[remain])));
                         }
-                        
+
                         /* fill array up to desired size */
                         if ((remain = (DCL_ELEM (type) - ilen)) > 0)
                                 while (remain--)
@@ -644,7 +644,7 @@ printIvalChar (sym_link * type, initList * ilist, pBlock *pb, char *s)
         }
         else {
                 //printChar (oFile, s, strlen (s) + 1);
-                
+
                 for(remain=0; remain<(int)strlen(s); remain++) {
                         addpCode2pBlock(pb,newpCode(POC_RETLW,newpCodeOpLit(s[remain])));
                         //fprintf(stderr,"0x%02x ",s[remain]);
@@ -657,7 +657,7 @@ printIvalChar (sym_link * type, initList * ilist, pBlock *pb, char *s)
 /*-----------------------------------------------------------------*/
 /* printIvalArray - generates code for array initialization        */
 /*-----------------------------------------------------------------*/
-static void 
+static void
 printIvalArray (symbol * sym, sym_link * type, initList * ilist,
                                 pBlock *pb)
 {
@@ -718,23 +718,23 @@ printIvalArray (symbol * sym, sym_link * type, initList * ilist,
 /*-----------------------------------------------------------------*/
 extern value *initPointer (initList *, sym_link *toType);
 
-static void 
+static void
 printIvalPtr (symbol * sym, sym_link * type, initList * ilist, pBlock *pb)
 {
         value *val;
-        
+
         if (!ilist || !pb)
                 return;
-        
+
         fprintf (stderr, "FIXME: initializers for pointers...\n");
         printTypeChain (type, stderr);
-        
+
         fprintf (stderr, "symbol: %s, DCL_TYPE():%d, DCL_ELEM():%d, IS_ARRAY():%d", sym->rname, DCL_TYPE(type), DCL_ELEM(type), IS_ARRAY(type));
         fprintf (stderr, "ilist: type=%d (INIT_DEEP=%d, INIT_NODE=%d)\n", ilist->type, INIT_DEEP, INIT_NODE);
 
         if (ilist && (ilist->type == INIT_DEEP))
           ilist = ilist->init.deep;
-        
+
         /* function pointers */
         if (IS_FUNC (type->next))
         {
@@ -744,7 +744,7 @@ printIvalPtr (symbol * sym, sym_link * type, initList * ilist, pBlock *pb)
 
         if (!(val = initPointer (ilist, type)))
                 return;
-        
+
         if (IS_CHAR (type->next))
         {
                 if (printIvalChar (type, ilist, pb, NULL)) return;
@@ -799,12 +799,12 @@ printIvalPtr (symbol * sym, sym_link * type, initList * ilist, pBlock *pb)
 /*-----------------------------------------------------------------*/
 /* printIval - generates code for initial value                    */
 /*-----------------------------------------------------------------*/
-static void 
+static void
 printIval (symbol * sym, sym_link * type, initList * ilist, pBlock *pb)
 {
         if (!ilist || !pb)
                 return;
-        
+
         /* if structure then    */
         if (IS_STRUCT (type))
         {
@@ -812,7 +812,7 @@ printIval (symbol * sym, sym_link * type, initList * ilist, pBlock *pb)
                 printIvalStruct (sym, type, ilist, pb);
                 return;
         }
-        
+
         /* if this is an array   */
         if (IS_ARRAY (type))
         {
@@ -820,7 +820,7 @@ printIval (symbol * sym, sym_link * type, initList * ilist, pBlock *pb)
                 printIvalArray (sym, type, ilist, pb);
                 return;
         }
-        
+
         /* if this is a pointer */
         if (IS_PTR (type))
         {
@@ -828,7 +828,7 @@ printIval (symbol * sym, sym_link * type, initList * ilist, pBlock *pb)
                 printIvalPtr (sym, type, ilist, pb);
                 return;
         }
-        
+
         /* if type is SPECIFIER */
         if (IS_SPEC (type))
         {
@@ -848,11 +848,11 @@ static void
 pic14emitStaticSeg (memmap * map)
 {
         symbol *sym;
-        
+
         dbuf_printf (&map->oBuf, ";\t.area\t%s\n", map->sname);
-        
+
         //fprintf(stderr, "%s\n",__FUNCTION__);
-        
+
         /* for all variables in this segment do */
         for (sym = setFirstItem (map->syms); sym;
         sym = setNextItem (map->syms))
@@ -862,12 +862,12 @@ pic14emitStaticSeg (memmap * map)
                         addSetHead (&externs, sym);
                         continue;
                 }
-                
+
                 /* if it is not static add it to the public
                 table */
                 if (!IS_STATIC (sym->etype))
                         addSetHead (&publics, sym);
-                
+
                 /* print extra debug info if required */
                 if (options.debug || sym->level == 0)
                 {
@@ -883,15 +883,15 @@ pic14emitStaticSeg (memmap * map)
                                 dbuf_printf (&code->oBuf, "L%s_",
                                 (sym->localof ? sym->localof->name : "-null-"));
                         dbuf_printf (&code->oBuf, "%s_%d_%d", sym->name, sym->level, sym->block);
-                        
+
                 }
-                
+
                 /* if it has an absolute address */
                 if (SPEC_ABSA (sym->etype))
                 {
                         if (options.debug || sym->level == 0)
                                 dbuf_printf (&code->oBuf, " == 0x%04x\n", SPEC_ADDR (sym->etype));
-                        
+
                         dbuf_printf (&code->oBuf, "%s\t=\t0x%04x\n",
                                 sym->rname,
                                 SPEC_ADDR (sym->etype));
@@ -900,13 +900,13 @@ pic14emitStaticSeg (memmap * map)
                 {
                         if (options.debug || sym->level == 0)
                                 dbuf_printf (&code->oBuf, " == .\n");
-                        
+
                         /* if it has an initial value */
                         if (sym->ival)
                         {
 #if 0
                                 pBlock *pb;
-                                
+
                                 dbuf_printf (&code->oBuf, "%s:\n", sym->rname);
                                 noAlloc++;
                                 resolveIvalSym (sym->ival, sym->type);
@@ -914,14 +914,14 @@ pic14emitStaticSeg (memmap * map)
                                 pb = newpCodeChain(NULL, 'P',newpCodeCharP("; Starting pCode block for Ival"));
                                 addpBlock(pb);
                                 addpCode2pBlock(pb,newpCodeLabel(sym->rname,-1));
-                                
+
                                 printIval (sym, sym->type, sym->ival, pb);
                                 noAlloc--;
 #endif
                         }
                         else
                         {
-                                
+
                                 /* allocate space */
                                 dbuf_printf (&code->oBuf, "%s:\n", sym->rname);
                                 /* special case for character strings */
@@ -936,7 +936,7 @@ pic14emitStaticSeg (memmap * map)
                         }
                 }
         }
-        
+
 }
 #endif
 
@@ -973,7 +973,7 @@ pic14createInterruptVect (struct dbuf_s * vBuf)
 {
         mainf = newSymbol ("main", 0);
         mainf->block = 0;
-        
+
         /* only if the main function exists */
         if (!(mainf = findSymWithLevel (SymbolTab, mainf)))
         {
@@ -983,7 +983,7 @@ pic14createInterruptVect (struct dbuf_s * vBuf)
                         fprintf(stderr,"WARNING: function 'main' undefined\n");
                 return;
         }
-        
+
         /* if the main is only a prototype ie. no body then do nothing */
         if (!IFFUNC_HASBODY(mainf->type))
         {
@@ -993,7 +993,7 @@ pic14createInterruptVect (struct dbuf_s * vBuf)
                         fprintf(stderr,"WARNING: function 'main' undefined\n");
                 return;
         }
-        
+
         dbuf_printf (vBuf, "%s", iComments2);
         dbuf_printf (vBuf, "; reset vector \n");
         dbuf_printf (vBuf, "%s", iComments2);
@@ -1014,7 +1014,7 @@ pic14initialComments (FILE * afile)
         initialComments (afile);
         fprintf (afile, "; PIC port for the 14-bit core\n");
         fprintf (afile, iComments2);
-        
+
 }
 
 int
@@ -1106,11 +1106,11 @@ static void
 pic14printExterns (FILE * afile)
 {
         symbol *sym;
-        
+
         fprintf (afile, "%s", iComments2);
         fprintf (afile, "; extern variables in this module\n");
         fprintf (afile, "%s", iComments2);
-        
+
         for (sym = setFirstItem (externs); sym; sym = setNextItem (externs))
                 pic14_emitSymbolIfNew(afile, "\textern %s\n", sym->rname, 1);
 }
@@ -1155,7 +1155,7 @@ pic14printPublics (FILE * afile)
 int
 pic14_operandsAllocatedInSameBank(const char *str1, const char *str2) {
     // see pic14printLocals
-    
+
     if (getenv("SDCC_PIC14_SPLIT_LOCALS")) {
         // no clustering applied, each register resides in its own bank
     } else {
@@ -1223,44 +1223,44 @@ static void
 pic14emitOverlay (struct dbuf_s * aBuf)
 {
         set *ovrset;
-        
+
         /*  if (!elementsInSet (ovrSetSets))*/
-        
+
         /* the hack below, fixes translates for devices which
         * only have udata_shr memory */
         dbuf_printf (aBuf, "%s\t%s\n",
                 (elementsInSet(ovrSetSets)?"":";"),
                 port->mem.overlay_name);
-        
+
         /* for each of the sets in the overlay segment do */
         for (ovrset = setFirstItem (ovrSetSets); ovrset;
         ovrset = setNextItem (ovrSetSets))
         {
-                
+
                 symbol *sym;
-                
+
                 if (elementsInSet (ovrset))
                 {
                 /* this dummy area is used to fool the assembler
                 otherwise the assembler will append each of these
                 declarations into one chunk and will not overlay
                         sad but true */
-                        
+
                         /* I don't think this applies to us. We are using gpasm.  CRF */
-                        
+
                         dbuf_printf (aBuf, ";\t.area _DUMMY\n");
                         /* output the area informtion */
                         dbuf_printf (aBuf, ";\t.area\t%s\n", port->mem.overlay_name);   /* MOF */
                 }
-                
+
                 for (sym = setFirstItem (ovrset); sym;
                 sym = setNextItem (ovrset))
                 {
-                        
+
                         /* if extern then do nothing */
                         if (IS_EXTERN (sym->etype))
                                 continue;
-                        
+
                                 /* if allocation required check is needed
                                 then check if the symbol really requires
                         allocation only for local variables */
@@ -1268,18 +1268,18 @@ pic14emitOverlay (struct dbuf_s * aBuf)
                                 !(sym->_isparm && !IS_REGPARM (sym->etype))
                                 && !sym->allocreq && sym->level)
                                 continue;
-                        
+
                                 /* if global variable & not static or extern
                         and addPublics allowed then add it to the public set */
                         if ((sym->_isparm && !IS_REGPARM (sym->etype))
                                 && !IS_STATIC (sym->etype))
                                 addSetHead (&publics, sym);
-                        
+
                                 /* if extern then do nothing or is a function
                         then do nothing */
                         if (IS_FUNC (sym->type))
                                 continue;
-                        
+
                         /* print extra debug info if required */
                         if (options.debug || sym->level == 0)
                         {
@@ -1296,15 +1296,15 @@ pic14emitOverlay (struct dbuf_s * aBuf)
                                         (sym->localof ? sym->localof->name : "-null-"));
                                 dbuf_printf (aBuf, "%s_%d_%d", sym->name, sym->level, sym->block);
                         }
-                        
+
                         /* if is has an absolute address then generate
                         an equate for this no need to allocate space */
                         if (SPEC_ABSA (sym->etype))
                         {
-                                
+
                                 if (options.debug || sym->level == 0)
                                         dbuf_printf (aBuf, " == 0x%04x\n", SPEC_ADDR (sym->etype));
-                                
+
                                 dbuf_printf (aBuf, "%s\t=\t0x%04x\n",
                                         sym->rname,
                                         SPEC_ADDR (sym->etype));
@@ -1313,12 +1313,12 @@ pic14emitOverlay (struct dbuf_s * aBuf)
                         {
                                 if (options.debug || sym->level == 0)
                                         dbuf_printf (aBuf, "==.\n");
-                                
+
                                 /* allocate space */
                                 dbuf_printf (aBuf, "%s:\n", sym->rname);
                                 dbuf_printf (aBuf, "\t.ds\t0x%04x\n", (unsigned int) getSize (sym->type) & 0xffff);
                         }
-                        
+
                 }
         }
 }
@@ -1337,11 +1337,11 @@ pic14_emitInterruptHandler (FILE * asmFile)
                 // Note: Do NOT name this code_interrupt to avoid nameclashes with
                 //       source files's code segment (interrupt.c -> code_interrupt)
                 fprintf (asmFile, "c_interrupt\t%s\t0x4\n", CODE_NAME);
-                
+
                 /* interrupt service routine */
                 fprintf (asmFile, "__sdcc_interrupt\n");
                 copypCode(asmFile, 'I');
-        }       
+        }
 }
 
 /*-----------------------------------------------------------------*/
@@ -1373,39 +1373,39 @@ picglue ()
 
 #if 0
         if (mainf && IFFUNC_HASBODY(mainf->type)) {
-                
+
                 pBlock *pb = newpCodeChain(NULL,'X',newpCodeCharP("; Starting pCode block"));
                 addpBlock(pb);
-                
+
                 /* entry point @ start of CSEG */
                 addpCode2pBlock(pb,newpCodeLabel("__sdcc_program_startup",-1));
                 /* put in the call to main */
                 addpCode2pBlock(pb,newpCode(POC_CALL,newpCodeOp("_main",PO_STR)));
-                
+
                 if (options.mainreturn) {
-                        
+
                         addpCode2pBlock(pb,newpCodeCharP(";\treturn from main will return to caller\n"));
                         addpCode2pBlock(pb,newpCode(POC_RETURN,NULL));
-                        
+
                 } else {
-                        
+
                         addpCode2pBlock(pb,newpCodeCharP(";\treturn from main will lock up\n"));
                         addpCode2pBlock(pb,newpCode(POC_GOTO,newpCodeOp("$",PO_STR)));
-                        
+
                 }
         }
-#endif  
-        
+#endif
+
         /* At this point we've got all the code in the form of pCode structures */
         /* Now it needs to be rearranged into the order it should be placed in the */
         /* code space */
-        
+
         movepBlock2Head('P');              // Last
         movepBlock2Head(code->dbName);
         movepBlock2Head('X');
         movepBlock2Head(statsg->dbName);   // First
-        
-        
+
+
         /* print the global struct definitions */
         if (options.debug)
                 cdbStructBlock (0);
@@ -1414,27 +1414,27 @@ picglue ()
         //pic14emitMaps ();
         /* do the overlay segments */
         pic14emitOverlay(&ovrBuf);
-        
+
         /* PENDING: this isnt the best place but it will do */
         if (port->general.glue_up_main) {
                 /* create the interrupt vector table */
                 pic14createInterruptVect (&vBuf);
         }
-        
+
         AnalyzepCode('*');
-        
+
         ReuseReg(); // ReuseReg where call tree permits
-        
+
         InlinepCode();
-        
+
         AnalyzepCode('*');
-        
+
         if (options.debug) pcode_test();
-        
-        
+
+
         /* now put it all together into the assembler file */
         /* create the assembler file name */
-        
+
         if ((noAssemble || options.c1mode) && fullDstFileName)
         {
                 sprintf (buffer, fullDstFileName);
@@ -1444,7 +1444,7 @@ picglue ()
                 sprintf (buffer, dstFileName);
                 strcat (buffer, ".asm");
         }
-        
+
         if (!(asmFile = fopen (buffer, "w"))) {
                 werror (E_FILE_OPEN_ERR, buffer);
                 exit (1);
@@ -1452,14 +1452,14 @@ picglue ()
 
         /* prepare statistics */
         resetpCodeStatistics ();
-        
+
         /* initial comments */
         pic14initialComments (asmFile);
-        
+
         /* print module name */
         fprintf (asmFile, "%s\t.file\t\"%s\"\n",
-           options.debug ? "" : ";", fullSrcFileName);
-        
+            options.debug ? "" : ";", fullSrcFileName);
+
         /* Let the port generate any global directives, etc. */
         if (port->genAssemblerPreamble)
         {
@@ -1468,18 +1468,18 @@ picglue ()
 
         /* print the global variables in this module */
         //pic14printPublics (asmFile);
-        
+
         /* print the extern variables in this module */
         //pic14printExterns (asmFile);
-        
+
         /* copy the sfr segment */
 #if 0
         fprintf (asmFile, "%s", iComments2);
         fprintf (asmFile, "; special function registers\n");
         fprintf (asmFile, "%s", iComments2);
         dbuf_write_and_destroy (&sfr->oBuf, asmFile);
-        
-        
+
+
         if (udata_section_name) {
                 sprintf(udata_name,"%s",udata_section_name);
         } else {
@@ -1500,24 +1500,24 @@ picglue ()
 
         /* print the locally defined variables in this module */
         writeUsedRegs(asmFile);
-        
+
         /* create the overlay segments */
         fprintf (asmFile, "%s", iComments2);
         fprintf (asmFile, "; overlayable items in internal ram \n");
-        fprintf (asmFile, "%s", iComments2);    
+        fprintf (asmFile, "%s", iComments2);
         dbuf_write_and_destroy (&ovrBuf, asmFile);
-        
+
 #if 0
-        
+
         /* create the stack segment MOF */
         if (mainf && IFFUNC_HASBODY(mainf->type)) {
                 fprintf (asmFile, "%s", iComments2);
                 fprintf (asmFile, "; Stack segment in internal ram \n");
-                fprintf (asmFile, "%s", iComments2);    
+                fprintf (asmFile, "%s", iComments2);
                 fprintf (asmFile, ";\t.area\tSSEG\t(DATA)\n"
                         ";__start__stack:\n;\t.ds\t1\n\n");
         }
-        
+
         /* create the idata segment */
         fprintf (asmFile, "%s", iComments2);
         fprintf (asmFile, "; indirectly addressable internal ram data\n");
@@ -1532,7 +1532,7 @@ picglue ()
                 fprintf (asmFile,";\t.area XSEG (XDATA)\n"); /* MOF */
                 fprintf (asmFile,";\t.ds 256\n");
         }
-        
+
         /* copy xtern ram data */
         fprintf (asmFile, "%s", iComments2);
         fprintf (asmFile, "; external ram data\n");
@@ -1540,7 +1540,7 @@ picglue ()
         dbuf_write_and_destroy (&xdata->oBuf, asmFile);
 
 #endif
-        
+
         /* copy the bit segment */
 #if 0
         fprintf (asmFile, "%s", iComments2);
@@ -1557,29 +1557,29 @@ picglue ()
 
         /* create interupt ventor handler */
         pic14_emitInterruptHandler (asmFile);
-        
+
         /* copy over code */
         fprintf (asmFile, "%s", iComments2);
         fprintf (asmFile, "; code\n");
         fprintf (asmFile, "%s", iComments2);
         fprintf (asmFile, "code_%s\t%s\n", moduleName, port->mem.code_name);
-        
+
         /* unknown */
         copypCode(asmFile, 'X');
-        
+
         /* _main function */
         copypCode(asmFile, 'M');
-        
+
         /* other functions */
         copypCode(asmFile, code->dbName);
-        
+
         /* unknown */
         copypCode(asmFile, 'P');
 
         dumppCodeStatistics (asmFile);
-        
+
         fprintf (asmFile,"\tend\n");
-        
+
         fclose (asmFile);
         pic14_debugLogClose();
 }
@@ -1654,7 +1654,7 @@ parseIvalAst (ast *node, int *inCodeSpace) {
 #define LEN 4096
     char *buffer = NULL;
     char *left, *right;
-    
+
     if (IS_AST_VALUE(node)) {
         value *val = AST_VALUE(node);
         symbol *sym = IS_AST_SYM_VALUE(node) ? AST_SYMBOL(node) : NULL;
@@ -1669,7 +1669,7 @@ parseIvalAst (ast *node, int *inCodeSpace) {
         {
             *inCodeSpace = 1;
         }
-        
+
         DEBUGprintf ("%s: AST_VALUE\n", __FUNCTION__);
         if (IS_AST_LIT_VALUE(node)) {
             buffer = Safe_alloc(LEN);
@@ -1726,12 +1726,12 @@ parseIvalAst (ast *node, int *inCodeSpace) {
     } else {
         assert ( !"Invalid construct in initializer." );
     }
-    
+
     return (buffer);
 }
 
 /*
- * Emit the section preamble, absolute location (if any) and 
+ * Emit the section preamble, absolute location (if any) and
  * symbol name(s) for intialized data.
  */
 static int
@@ -1740,7 +1740,7 @@ emitIvalLabel(struct dbuf_s *oBuf, symbol *sym)
     char *segname;
     static int in_code = 0;
     static int sectionNr = 0;
-    
+
     if (sym) {
         // code or data space?
         if (IS_CODE(getSpec(sym->type))) {
@@ -1776,11 +1776,11 @@ emitIvals(struct dbuf_s *oBuf, symbol *sym, initList *list, long lit, int size)
     int inCodeSpace = 0;
     char *str = NULL;
     int in_code;
-    
+
     assert (size <= sizeof(long));
     assert (!list || (list->type == INIT_NODE));
     node = list ? list->init.node : NULL;
-    
+
     in_code = emitIvalLabel(oBuf, sym);
     if (!in_code) dbuf_printf (oBuf, "\tdb\t");
 
@@ -1796,7 +1796,7 @@ emitIvals(struct dbuf_s *oBuf, symbol *sym, initList *list, long lit, int size)
         dbuf_printf (oBuf, "\n");
         return;
     } // if
-    
+
     op = NULL;
     if (constExprTree(node) && (val = constExprValue(node, 0))) {
         op = operandFromValue(val);
@@ -1812,12 +1812,12 @@ emitIvals(struct dbuf_s *oBuf, symbol *sym, initList *list, long lit, int size)
         assert ( !"Unhandled construct in intializer." );
     }
 
-    if (op) { 
+    if (op) {
         aopOp(op, NULL, 1);
         assert(AOP(op));
         //printOperand(op, of);
     }
-    
+
     for (i=0; i < size; i++) {
         char *text = op ? aopGet(AOP(op), i, 0, 0)
             : get_op(newpCodeOpImmd(str, i, 0, inCodeSpace, 0), NULL, 0);
@@ -1840,11 +1840,11 @@ static sym_link *
 matchIvalToUnion (initList *list, sym_link *type, int size)
 {
     symbol *sym;
-    
+
     assert (type);
 
     if (IS_PTR(type) || IS_CHAR(type) || IS_INT(type) || IS_LONG(type)
-            || IS_FLOAT(type)) 
+            || IS_FLOAT(type))
     {
         if (!list || (list->type == INIT_NODE)) {
             DEBUGprintf ("OK, simple type\n");
@@ -1874,13 +1874,13 @@ matchIvalToUnion (initList *list, sym_link *type, int size)
                 if (list) list = list->next;
                 sym = sym->next;
             } // while
-            
+
             // excess initializers?
             if (list) {
                 DEBUGprintf ("ERROR, excess initializers\n");
                 return (NULL);
             }
-            
+
             DEBUGprintf ("OK, struct\n");
             return (type);
         }
@@ -1956,20 +1956,20 @@ emitInitVal(struct dbuf_s *oBuf, symbol *topsym, sym_link *my_type, initList *li
         } // for i
         return;
     }
-    
+
     if (IS_FLOAT(my_type)) {
         // float, 32 bit
         DEBUGprintf ("(float, %d byte) %lf\n", size, list ? list2int(list) : 0.0);
         emitIvals(oBuf, topsym, list, 0, size);
         return;
     }
-    
+
     if (IS_CHAR(my_type) || IS_INT(my_type) || IS_LONG(my_type)) {
         // integral type, 8, 16, or 32 bit
         DEBUGprintf ("(integral, %d byte) 0x%lx/%ld\n", size, list ? (long)list2int(list) : 0, list ? (long)list2int(list) : 0);
         emitIvals(oBuf, topsym, list, 0, size);
         return;
-        
+
     } else if (IS_STRUCT(my_type) && SPEC_STRUCT(my_type)->type == STRUCT) {
         // struct
         DEBUGprintf ("(struct, %d byte) handled below\n", size);
@@ -1983,7 +1983,7 @@ emitInitVal(struct dbuf_s *oBuf, symbol *topsym, sym_link *my_type, initList *li
             int len = 0;
             if (IS_BITFIELD(sym->type)) {
                 while (sym && IS_BITFIELD(sym->type)) {
-                    assert (!list || ((list->type == INIT_NODE) 
+                    assert (!list || ((list->type == INIT_NODE)
                                 && IS_AST_LIT_VALUE(list->init.node)));
                     lit = (long) (list ? list2int(list) : 0);
                     DEBUGprintf ( "(bitfield member) %02lx (%d bit, starting at %d, bitfield %02lx)\n",
@@ -2000,7 +2000,7 @@ emitInitVal(struct dbuf_s *oBuf, symbol *topsym, sym_link *my_type, initList *li
                 emitIvals(oBuf, topsym, NULL, bitfield, len / 8);
                 topsym = NULL;
             } // if
-            
+
             if (sym) {
                 emitInitVal(oBuf, topsym, sym->type, list);
                 topsym = NULL;
@@ -2012,7 +2012,7 @@ emitInitVal(struct dbuf_s *oBuf, symbol *topsym, sym_link *my_type, initList *li
             assert ( !"Excess initializers." );
         } // if
         return;
-        
+
     } else if (IS_STRUCT(my_type) && SPEC_STRUCT(my_type)->type == UNION) {
         // union
         DEBUGprintf ("(union, %d byte) handled below\n", size);
@@ -2030,11 +2030,11 @@ emitInitVal(struct dbuf_s *oBuf, symbol *topsym, sym_link *my_type, initList *li
             }
             return;
         } // if
-        
+
         assert ( !"No UNION member matches the initializer structure.");
     } else if (IS_BITFIELD(my_type)) {
         assert ( !"bitfields should only occur in structs..." );
-        
+
     } else {
         printf ("SPEC_NOUN: %d\n", SPEC_NOUN(my_type));
         assert( !"Unhandled initialized type.");
@@ -2153,7 +2153,7 @@ showAllMemmaps(FILE *of)
         //DEBUGprintf ("memmap %i: %p\n", i, map);
         if (map) {
 #if 0
-            fprintf (stdout, ";  pageno %c, sname %s, dbName %c, ptrType %d, slbl %d, sloc %u, fmap %u, paged %u, direct %u, bitsp %u, codesp %u, regsp %u, syms %p\n", 
+            fprintf (stdout, ";  pageno %c, sname %s, dbName %c, ptrType %d, slbl %d, sloc %u, fmap %u, paged %u, direct %u, bitsp %u, codesp %u, regsp %u, syms %p\n",
                     map->pageno, map->sname, map->dbName, map->ptrType, map->slbl,
                     map->sloc, map->fmap, map->paged, map->direct, map->bitsp,
                     map->codesp, map->regsp, map->syms);
index a0a1e257d3a14ce289af71d1428c2695ed6de9a5..d2a25e369b563b5a0830ba6953ba21520525eb83 100644 (file)
@@ -601,7 +601,7 @@ pic16_printIvalType (symbol *sym, sym_link * type, initList * ilist, char ptype,
 
   if (!(val = list2val (ilist))) {
     // assuming a warning has been thrown
-    val=constVal("0");
+    val = constCharVal (0);
   }
 
   if (val->type != type) {
@@ -1025,7 +1025,7 @@ void pic16_printIvalFuncPtr (sym_link * type, initList * ilist, char ptype, void
 
   if (!val) {
     // an error has been thrown already
-    val=constVal("0");
+    val = constCharVal (0);
   }
 
   if (IS_LITERAL(val->etype)) {