extern unsigned long pic16_countInstructions();
set *pic16_localFunctions = NULL;
-set *rel_idataSymSet=NULL;
-set *fix_idataSymSet=NULL;
-
-extern DEFSETFUNC (closeTmpFiles);
-extern DEFSETFUNC (rmTmpFiles);
+set *rel_idataSymSet = NULL;
+set *fix_idataSymSet = NULL;
extern void pic16_AnalyzeBanking (void);
-extern void pic16_OptimizeJumps ();
-extern void pic16_OptimizeBanksel ();
-extern void pic16_InlinepCode(void);
-extern void pic16_writeUsedRegs(FILE *);
+extern void pic16_OptimizeJumps (void);
+extern void pic16_OptimizeBanksel (void);
+extern void pic16_InlinepCode (void);
+extern void pic16_writeUsedRegs (FILE *);
extern void initialComments (FILE * afile);
extern void printPublics (FILE * afile);
-void pic16_pCodeInitRegisters(void);
-pCodeOp *pic16_popCopyReg(pCodeOpReg *pc);
-extern void pic16_pCodeConstString(char *name, char *value, unsigned length);
+void pic16_pCodeInitRegisters (void);
+pCodeOp *pic16_popCopyReg (pCodeOpReg *pc);
+extern void pic16_pCodeConstString (char *name, char *value, unsigned length);
/*-----------------------------------------------------------------*/
/* pic16_printIvalBitFields - generate initializer for bitfields */
/*-----------------------------------------------------------------*/
static void
-pic16_printIvalBitFields(symbol **sym, initList **ilist, char ptype, void *p)
+pic16_printIvalBitFields (symbol **sym, initList **ilist, char ptype, void *p)
{
- value *val ;
symbol *lsym = *sym;
- initList *lilist = *ilist ;
+ initList *lilist = *ilist;
unsigned long ival = 0;
+ int size = 0;
unsigned long i;
- int size =0;
#if DEBUG_PRINTIVAL
#endif
- do {
- val = list2val(lilist);
- if (size) {
- if (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) +
- (SPEC_BLEN (lsym->etype) % 8 ? 1 : 0));
+ while (lsym)
+ {
+ if (0 == SPEC_BLEN (lsym->etype))
+ {
+ /* bit-field structure member with a width of 0 */
+ lsym = lsym->next;
+ break;
+ }
+ else if (!SPEC_BUNNAMED (lsym->etype))
+ {
+ /* not an unnamed bit-field structure member */
+ value *val = list2val (lilist);
+ int bit_length = SPEC_BLEN (lsym->etype);
+
+ if (size)
+ {
+ if (bit_length > 8)
+ size += (bit_length + 7) / 8;
+ }
+ else
+ size = (bit_length + 7) / 8;
+
+ ival |= (ulFromVal (val) & ((1ul << bit_length) - 1ul)) << SPEC_BSTR (lsym->etype);
+ lilist = (lilist ? lilist->next : NULL);
+ }
+ lsym = lsym->next;
}
- i = (ulFromVal (val) & ((1ul << SPEC_BLEN (lsym->etype)) - 1ul));
- i <<= SPEC_BSTR (lsym->etype);
- ival |= i;
- if (! ( lsym->next &&
- (lilist && lilist->next) &&
- (IS_BITFIELD(lsym->next->type)) &&
- (SPEC_BSTR(lsym->next->etype)))) break;
- lsym = lsym->next;
- lilist = lilist->next;
- } while (1);
-
- for (i = 0; i < size; i++) {
- pic16_emitDB(BYTE_IN_LONG(ival, i), ptype, p);
- } // for
+
+ for (i = 0; i < size; i++)
+ pic16_emitDB (BYTE_IN_LONG (ival, i), ptype, p);
*sym = lsym;
*ilist = lilist;
sflds = SPEC_STRUCT (type)->fields;
- if (ilist) {
- if (ilist->type != INIT_DEEP) {
- werrorfl (sym->fileDef, sym->lineDef, E_INIT_STRUCT, sym->name);
- return;
- }
+ if (ilist)
+ {
+ if (ilist->type != INIT_DEEP)
+ {
+ werrorfl (sym->fileDef, sym->lineDef, E_INIT_STRUCT, sym->name);
+ return;
+ }
- iloop = ilist->init.deep;
- }
+ iloop = ilist->init.deep;
+ }
- for (; sflds; sflds = sflds->next, iloop = (iloop ? iloop->next : NULL)) {
-// fprintf(stderr, "%s:%d sflds: %p\tiloop = %p\n", __FILE__, __LINE__, sflds, iloop);
- if (IS_BITFIELD(sflds->type)) {
- pic16_printIvalBitFields(&sflds, &iloop, ptype, p);
- } else {
- pic16_printIval (sym, sflds->type, iloop, ptype, p);
+ while (sflds)
+ {
+// fprintf(stderr, "%s:%d sflds: %p\tiloop = %p\n", __FILE__, __LINE__, sflds, iloop);
+ if (IS_BITFIELD (sflds->type))
+ {
+ pic16_printIvalBitFields (&sflds, &iloop, ptype, p);
+ }
+ else
+ {
+ pic16_printIval (sym, sflds->type, iloop, ptype, p);
+ sflds = sflds->next;
+ iloop = iloop ? iloop->next : NULL;
+ }
}
- }
- if (iloop) {
+ if (iloop)
werrorfl (sym->fileDef, sym->lineDef, W_EXCESS_INITIALIZERS, "struct", sym->name);
- }
- return;
}
/*-----------------------------------------------------------------*/
if (pic16_mplab_comp) {
fprintf(afile, "; * MPLAB/MPASM/MPASMWIN/MPLINK compatibility mode enabled\n");
} // if
- fprintf (afile, iComments2);
+ fprintf (afile, "%s", iComments2);
if (options.debug) {
fprintf (afile, "\n\t.ident \"SDCC version %s #%s [pic16 port]%s\"\n",
if(pic16_options.dumpcalltree) {
FILE *cFile;
- sprintf(buffer, dstFileName);
+ sprintf(buffer, "%s", dstFileName);
strcat(buffer, ".calltree");
cFile = fopen(buffer, "w");
pic16_printCallTree( cFile );
/* now put it all together into the assembler file */
/* create the assembler file name */
if((noAssemble || options.c1mode) && fullDstFileName) {
- sprintf (buffer, fullDstFileName);
+ sprintf (buffer, "%s", fullDstFileName);
} else {
- sprintf (buffer, dstFileName);
+ sprintf (buffer, "%s", dstFileName);
strcat (buffer, ".asm");
}