From: tecodev Date: Thu, 8 Dec 2005 18:32:59 +0000 (+0000) Subject: * src/pic/device.c: renamed is_shared to pic14_is_shared X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=11f94633fa2b5ad6e35e3d430180888bec231d81;p=fw%2Fsdcc * 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 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4004 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index 255e086d..336adeb7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-12-08 Raphael Neider + + * 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 * device/lib/Makefile.in: fixed to enable port-specific-objects diff --git a/src/pic/device.c b/src/pic/device.c index 62369f1d..fea8565c 100644 --- a/src/pic/device.c +++ b/src/pic/device.c @@ -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; diff --git a/src/pic/gen.c b/src/pic/gen.c index d40d3f11..9bd3fc3f 100644 --- a/src/pic/gen.c +++ b/src/pic/gen.c @@ -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); } /*-----------------------------------------------------------------*/ diff --git a/src/pic/glue.c b/src/pic/glue.c index 7868be5b..6f69194a 100644 --- a/src/pic/glue.c +++ b/src/pic/glue.c @@ -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);