* src/pic/device.c: renamed is_shared to pic14_is_shared
authortecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 8 Dec 2005 18:32:59 +0000 (18:32 +0000)
committertecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 8 Dec 2005 18:32:59 +0000 (18:32 +0000)
* src/pic/gen.c (genIfx): re-enabled handling of sbits
* src/pic/glue.c (emitSymbolToFile): added workaround for sbits,
  (is_valid_identifier): added for above workaround

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

ChangeLog
src/pic/device.c
src/pic/gen.c
src/pic/glue.c

index 255e086dbc44f64aa8fb0a234625876468dce9e8..336adeb7401aec60da18c2d7f31733b2b0b3f217 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2005-12-08 Raphael Neider <rneider AT web.de>
+
+       * src/pic/device.c: renamed is_shared to pic14_is_shared
+       * src/pic/gen.c (genIfx): re-enabled handling of sbits
+       * src/pic/glue.c (emitSymbolToFile): added workaround for sbits,
+         (is_valid_identifier): added for above workaround
+
 2005-12-07 Maarten Brock <sourceforge.brock AT dse.nl>
 
        * device/lib/Makefile.in: fixed to enable port-specific-objects
index 62369f1d41eb3c235dbcae329defd2fe62367409..fea8565c9f86da32bab0c096473278b0e7308914 100644 (file)
@@ -106,7 +106,7 @@ AssignedMemory *finalMapping=NULL;
 
 static unsigned int config_word = DEFAULT_CONFIG_WORD;
 
-extern int is_shared (regs *reg);
+extern int pic14_is_shared (regs *reg);
 extern void emitSymbolToFile (FILE *of, const char *name, const char *section_type, int size, int addr, int useEQU, int globalize);
 
 void addMemRange(memRange *r, int type)
@@ -255,12 +255,12 @@ void dump_sfr(FILE *of)
                
                if (reg && !reg->isEmitted)
                {
-                 if (pic14_options.isLibrarySource && is_shared (reg))
+                 if (pic14_options.isLibrarySource && pic14_is_shared (reg))
                  {
                    /* rely on external declarations for the non-fixed stack */
                    fprintf (of, "\textern\t%s\n", reg->name);
                  } else {
-                   emitSymbolToFile (of, reg->name, "udata", reg->size, reg->isFixed ? reg->address : -1, 0, is_shared (reg));
+                   emitSymbolToFile (of, reg->name, "udata", reg->size, reg->isFixed ? reg->address : -1, 0, pic14_is_shared (reg));
                  }
                  
                  reg->isEmitted = 1;
index d40d3f1130250f377112d3c20f574458d43cb740..9bd3fc3f12aa7c84053f36ac514aebb04a5557e4 100644 (file)
@@ -9828,8 +9828,6 @@ static void genIfx (iCode *ic, iCode *popIc)
                pic14_toBoolean(cond);
        else
                isbit = 1;
-       /* the result is now in the accumulator */
-       freeAsmop(cond,NULL,ic,TRUE);
        
        /* if there was something to be popped then do it */
        if (popIc)
@@ -9841,13 +9839,16 @@ static void genIfx (iCode *ic, iCode *popIc)
                if (IC_TRUE(ic))
                {
                        assert (!IC_FALSE(ic));
-                       emitSKPNC;
+                       emitpcode(POC_BTFSC, popGet(AOP(cond), 0));
+                       //emitSKPNC;
                        emitpcode(POC_GOTO, popGetLabel(IC_TRUE(ic)->key));
                } else {
                        assert (IC_FALSE(ic));
-                       emitSKPC;
+                       emitpcode(POC_BTFSS, popGet(AOP(cond), 0));
+                       //emitSKPC;
                        emitpcode(POC_GOTO, popGetLabel(IC_FALSE(ic)->key));
                }
+               if (0)
                {
                        static int hasWarned = 0;
                        if (!hasWarned)
@@ -9873,6 +9874,8 @@ static void genIfx (iCode *ic, iCode *popIc)
        
        ic->generated = 1;
        
+       /* the result is now in the accumulator */
+       freeAsmop(cond,NULL,ic,TRUE);
 }
 
 /*-----------------------------------------------------------------*/
index 7868be5beb1eae3f0eb8e0b394eac8bf92936cf8..6f69194adc1a92fa56a24f8d4ab49192bc9c080f 100644 (file)
@@ -103,19 +103,47 @@ int pic14aopLiteral (value *val, int offset)
 
 /* Check whether the given reg is shared amongst all .o files of a project.
  * This is true for the pseudo stack and WSAVE, SSAVE and PSAVE. */
-int is_shared_address (int addr)
+static int
+is_shared_address (int addr)
 {
   return ((addr > Gstack_base_addr - 18)
        && (addr <= Gstack_base_addr));
 }
 
 int
-is_shared (regs *reg)
+pic14_is_shared (regs *reg)
 {
        if (!reg) return 0;
        return is_shared_address (reg->address);
 }
 
+static int
+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')
+       || (a == '_')))
+    return 0;
+
+  name++;
+  while ((a = *name++))
+  {
+    if (!((a >= 'a' && a <= 'z')
+       || (a >= 'A' && a <= 'Z')
+       || (a >= '0' && a <= '9')
+       || (a == '_')))
+      return 0;
+  } // while
+
+  /* valid identifier */
+  return 1;
+}
+
 /* set of already emitted symbols; we store only pointers to the emitted
  * symbol names so these MUST NO BE CHANGED afterwards... */
 static set *symbolsEmitted = NULL;
@@ -129,6 +157,16 @@ emitSymbolToFile (FILE *of, const char *name, const char *section_type, int size
 {
        const char *sym;
        static unsigned int sec_idx = 0;
+
+       /* workaround: variables declared via `sbit' result in a numeric
+        * identifier (0xHH), EQU'ing them is invalid, so just ignore it.
+        * sbit is heavily used in the inc2h-generated header files!
+        */
+       if (!is_valid_identifier(name))
+       {
+         //fprintf( stderr, "%s:%s:%u: ignored symbol: %s\n", __FILE__, __FUNCTION__, __LINE__, name );
+         return;
+       }
        
        /* check whether the symbol is already defined */
        for (sym = (const char *) setFirstItem (symbolsEmitted);