for (sym = setFirstItem (map->syms); sym; sym = setNextItem (map->syms)) {
-#if 0
+#if 1
fprintf(stderr, "%s\t%s: sym: %s\tused: %d\textern: %d\tstatic: %d\taggregate: %d\tregister: 0x%x\tfunction: %d\n",
__FUNCTION__,
map->sname, sym->name, sym->used, IS_EXTERN(sym->etype), IS_STATIC(sym->etype),
}
/* if allocation required check is needed
- * then check if the symbol really requires
+ * then check if the symbol really requires
* allocation only for local variables */
if (arFlag && !IS_AGGREGATE (sym->type) &&
!(sym->_isparm && !IS_REGPARM (sym->etype)) &&
value *val;
int dLvl = 0;
+
+#if DEBUG_PRINTIVAL
+ fprintf(stderr, "%s\n",__FUNCTION__);
+#endif
+
if (ilist)
val = list2val (ilist);
else
pic16_printPointerType (val->name, ptype, p);
} else {
pic16_printPointerType (val->sym->rname, ptype, p);
+
+ if(IS_FUNC(val->sym->type) && !val->sym->used) {
+
+ /* this has not been declared as extern
+ * so declare it as a late extern just after the symbol */
+ if(ptype == 'p') {
+ pic16_addpCode2pBlock((pBlock *)p, pic16_newpCodeCharP("declare symbol as extern"));
+ pic16_addpCode2pBlock((pBlock *)p, pic16_newpCodeAsmDir("extern", "%s", val->sym->rname));
+ pic16_addpCode2pBlock((pBlock *)p, pic16_newpCodeCharP("continue variable declaration"));
+ } else
+ if(ptype == 'f') {
+ fprintf((FILE *)p, "declare symbol as extern");
+ fprintf((FILE *)p, "\textern\t%s\n", val->sym->rname);
+ fprintf((FILE *)p, "continue variable declaration");
+ }
+ }
}
return;
pic16emitStaticSeg (memmap * map)
{
symbol *sym;
+ static int didcode=0;
//fprintf(stderr, "%s\n",__FUNCTION__);
sym = setNextItem (map->syms))
{
-#if 0
+#if 1
fprintf(stderr, "%s\t%s: sym: %s\tused: %d\tSPEC_ABSA: %d\tSPEC_AGGREGATE: %d\tCODE: %d\n\
CODESPACE: %d\tCONST: %d\tPTRCONST: %d\tSPEC_CONST: %d\n", __FUNCTION__,
map->sname, sym->name, sym->used, SPEC_ABSA(sym->etype), IS_AGGREGATE(sym->type),
pb = pic16_newpCodeChain(NULL, 'P',pic16_newpCodeCharP("; Starting pCode block for Ival"));
pic16_addpBlock(pb);
- /* make sure that 'code' directive is emitted before */
- pic16_addpCode2pBlock(pb, pic16_newpCodeAsmDir("code", NULL));
+ if(!didcode) {
+ /* make sure that 'code' directive is emitted before, once */
+ pic16_addpCode2pBlock(pb, pic16_newpCodeAsmDir("code", NULL));
+
+ didcode++;
+ }
// fprintf(stderr, "%s:%d [2] generating init for label: %s\n", __FILE__, __LINE__, sym->rname);
/* copy the interrupt vector table */
if(mainf && IFFUNC_HASBODY(mainf->type)) {
- fprintf (asmFile, "%s", iComments2);
+ fprintf (asmFile, "\n%s", iComments2);
fprintf (asmFile, "; interrupt vector \n");
fprintf (asmFile, "%s", iComments2);
copyFile (asmFile, vFile);
}
/* copy global & static initialisations */
- fprintf (asmFile, "%s", iComments2);
+ fprintf (asmFile, "\n%s", iComments2);
fprintf (asmFile, "; global & static initialisations\n");
fprintf (asmFile, "%s", iComments2);