void printIval (symbol *, link *, initList *, FILE *);
extern int noAlloc;
set *publics = NULL; /* public variables */
+set *externs = NULL; /* Varibles that are declared as extern */
/* TODO: this should be configurable (DS803C90 uses more than 6) */
int maxInterrupts = 6;
+int allocInfo = 1;
extern int maxRegBank ;
symbol *mainf;
extern char *VersionString;
for (sym = setFirstItem (map->syms); sym;
sym = setNextItem (map->syms)) {
- /* if extern then do nothing */
- if (IS_EXTERN (sym->etype))
+ /* if extern then add it into the extern list */
+ if (IS_EXTERN (sym->etype)) {
+ addSetHead (&externs, sym);
continue;
+ }
/* if allocation required check is needed
then check if the symbol really requires
/* allocate space */
if ((options.debug || sym->level == 0) && !options.nodebug)
fprintf(map->oFile,"==.\n");
- tfprintf(map->oFile, "!labeldef\n", sym->rname);
+ if (IS_STATIC(sym->etype))
+ tfprintf(map->oFile, "!slabeldef\n", sym->rname);
+ else
+ tfprintf(map->oFile, "!labeldef\n", sym->rname);
tfprintf(map->oFile, "\t!ds\n", (unsigned int)getSize (sym->type) & 0xffff);
}
ival = newNode ('=', newAst (EX_VALUE, symbolVal (sym)),
decorateType (resolveSymbols (list2expr (sym->ival))));
codeOutFile = statsg->oFile;
+ allocInfo = 0;
eBBlockFromiCode (iCodeFromAst (ival));
+ allocInfo = 1;
sym->ival = NULL;
}
}
expr->left->opval.op == PTR_OP &&
IS_ADDRESS_OF_OP(expr->left->left))
return valForStructElem(expr->left->left->left,
- expr->left->right);
+ expr->left->right);
+
+ }
+ /* case 3. (((char *) &a) +/- constant) */
+ if (IS_AST_OP(expr) &&
+ (expr->opval.op == '+' || expr->opval.op == '-') &&
+ IS_AST_OP(expr->left) && expr->left->opval.op == CAST &&
+ IS_AST_OP(expr->left->right) &&
+ expr->left->right->opval.op == '&' &&
+ IS_AST_LIT_VALUE(expr->right)) {
+
+ return valForCastAggr(expr->left->right->left,
+ expr->left->left->opval.lnk,
+ expr->right,expr->opval.op);
+
}
wrong:
/* now generate the name */
if (!val->sym) {
- if (IS_LITERAL (val->etype))
- fprintf(oFile, "\t.byte %s,%s\n", aopLiteral(val, 0),aopLiteral(val, 1));
- else
+ if (port->use_dw_for_init)
+ tfprintf(oFile, "\t!dw %s\n", val->name);
+ else
fprintf(oFile, "\t.byte %s,(%s >> 8)\n", val->name,val->name);
}
- else
- fprintf(oFile, "\t.byte %s,(%s >> 8)\n", val->sym->rname,val->sym->rname);
+ else
+ if (port->use_dw_for_init)
+ tfprintf(oFile, "\t!dws\n", val->sym->rname);
+ else
+ fprintf(oFile, "\t.byte %s,(%s >> 8)\n", val->sym->rname,val->sym->rname);
return;
}
"\t!dbs\n", val->name) ;
break;
case 2:
- tfprintf(oFile, "\t!dws\n", val->name);
+ if (port->use_dw_for_init)
+ tfprintf(oFile, "\t!dws\n", val->name);
+ else
+ fprintf(oFile, "\t.byte %s,(%s >> 8)\n", val->name, val->name);
break;
/* PENDING: probably just 3 */
default:
/* PENDING: 0x02 or 0x%02x, CDATA? */
fprintf (oFile,
- "\t.byte %s,(%s >> 8),#0x02\n",
- val->name, val->name);
+ "\t.byte %s,(%s >> 8),#0x%02x\n",
+ val->name, val->name, (IS_PTR(val->type) ? DCL_TYPE(val->type) :
+ PTR_TYPE(SPEC_OCLS(val->etype))));
}
}
else {
break;
case 3:
- fprintf (oFile, "\t.byte %s,(%s >> 8),#0x02\n",
- val->name, val->name);
+ fprintf (oFile, "\t.byte %s,(%s >> 8),#0x%02x\n",
+ val->name, val->name,(IS_PTR(val->type) ? DCL_TYPE(val->type) :
+ PTR_TYPE(SPEC_OCLS(val->etype))));
}
return;
}
symbol *sym;
fprintf (afile, "%s", iComments2);
- fprintf (afile, "; publics variables in this module\n");
+ fprintf (afile, "; Public variables in this module\n");
fprintf (afile, "%s", iComments2);
for (sym = setFirstItem (publics); sym;
tfprintf(afile, "\t!global\n", sym->rname);
}
+/*-----------------------------------------------------------------*/
+/* printExterns - generates .global for externs */
+/*-----------------------------------------------------------------*/
+void printExterns (FILE * afile)
+{
+ symbol *sym;
+
+ fprintf (afile, "%s", iComments2);
+ fprintf (afile, "; Externals used\n");
+ fprintf (afile, "%s", iComments2);
+
+ for (sym = setFirstItem (externs); sym;
+ sym = setNextItem (externs))
+ tfprintf(afile, "\t!global\n", sym->rname);
+}
+
/*-----------------------------------------------------------------*/
/* emitOverlay - will emit code for the overlay stuff */
/*-----------------------------------------------------------------*/
for (sym = setFirstItem(ovrset); sym;
sym = setNextItem(ovrset)) {
-
- /* if extern then do nothing */
+
+ /* if extern then add it to the publics tabledo nothing */
if (IS_EXTERN (sym->etype))
continue;
/* print the global variables in this module */
printPublics (asmFile);
-
+ if (port->assembler.externGlobal)
+ printExterns (asmFile);
+
/* copy the sfr segment */
fprintf (asmFile, "%s", iComments2);
fprintf (asmFile, "; special function registers\n");