+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
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)
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;
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)
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)
ic->generated = 1;
+ /* the result is now in the accumulator */
+ freeAsmop(cond,NULL,ic,TRUE);
}
/*-----------------------------------------------------------------*/
/* 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;
{
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);