extern void AnalyzeBanking (void);
extern void copyFile (FILE * dest, FILE * src);
+extern void ReuseReg(void);
extern void InlinepCode(void);
extern void writeUsedRegs(FILE *);
void pCodeInitRegisters(void);
int getConfigWord(int address);
+char *udata_section_name=0; // FIXME Temporary fix to change udata section name -- VR
+
/*-----------------------------------------------------------------*/
/* aopLiteral - string from a literal value */
/*-----------------------------------------------------------------*/
!IS_STATIC (sym->etype))
addSetHead (&publics, sym);
+ // PIC code allocates its own registers - so ignore parameter variable generated by processFuncArgs()
+ if (sym->_isparm)
+ continue;
/* if extern then do nothing or is a function
then do nothing */
if (IS_FUNC (sym->type))
ival = initAggregates (sym, sym->ival, NULL);
else
ival = newNode ('=', newAst_VALUE(symbolVal (sym)),
- decorateType (resolveSymbols (list2expr (sym->ival))));
+ decorateType (resolveSymbols (list2expr (sym->ival)), RESULT_CHECK));
codeOutFile = statsg->oFile;
GcurMemmap = statsg;
eBBlockFromiCode (iCodeFromAst (ival));
for (sym = setFirstItem (map->syms); sym;
sym = setNextItem (map->syms))
{
- /* if it is "extern" then do nothing */
- if (IS_EXTERN (sym->etype))
- continue;
+ /* if extern then add it into the extern list */
+ if (IS_EXTERN (sym->etype)) {
+ addSetHead (&externs, sym);
+ continue;
+ }
/* if it is not static add it to the public
table */
fprintf (code->oFile, "%s:\n", sym->rname);
noAlloc++;
- resolveIvalSym (sym->ival);
+ resolveIvalSym (sym->ival, sym->type);
//printIval (sym, sym->type, sym->ival, code->oFile);
pb = newpCodeChain(NULL, 'P',newpCodeCharP("; Starting pCode block for Ival"));
addpBlock(pb);
if (!(mainf = findSymWithLevel (SymbolTab, mainf)))
{
if (!options.cc_only)
- werror (E_NO_MAIN);
+// werror (E_NO_MAIN);
+ fprintf(stderr,"WARNING: function 'main' undefined\n");
return;
}
{
/* if ! compile only then main function should be present */
if (!options.cc_only)
- werror (E_NO_MAIN);
+// werror (E_NO_MAIN);
+ fprintf(stderr,"WARNING: function 'main' undefined\n");
return;
}
fprintf (vFile, "%s", iComments2);
fprintf (vFile, "; reset vector \n");
fprintf (vFile, "%s", iComments2);
- fprintf (vFile, "STARTUP\t%s\n", CODE_NAME);
- fprintf (vFile, "\tnop\n"); /* first location used by incircuit debugger */
+ fprintf (vFile, "STARTUP\t%s\n", CODE_NAME); // Lkr file should place section STARTUP at address 0x0
+ fprintf (vFile, "\tnop\n"); /* first location for used by incircuit debugger */
fprintf (vFile, "\tgoto\t__sdcc_gsinit_startup\n");
-/* during an interrupt PCLATH must be cleared before a goto - delete me
- fprintf (vFile, "\tnop\n");
- fprintf (vFile, "\tgoto\t__sdcc_interrupt\n");
-*/
}
for (sym = setFirstItem (publics); sym;
sym = setNextItem (publics)) {
- if(!IS_BITFIELD(sym->type) && ((IS_FUNC(sym->type) || sym->allocreq)))
- fprintf (afile, "\tglobal %s\n", sym->rname);
- else
- fprintf (afile, ";\tglobal %s\n", sym->rname);
+
+ if(!IS_BITFIELD(sym->type) && ((IS_FUNC(sym->type) || sym->allocreq))) {
+ if (!IS_BITVAR(sym->type))
+ fprintf (afile, "\tglobal %s\n", sym->rname);
+ } else {
+ /* Absolute variables are defines in the asm file as equates and thus can not be made global. */
+ if (!SPEC_ABSA (sym->etype))
+ fprintf (afile, "\tglobal %s\n", sym->rname);
+ }
}
}
{
set *ovrset;
- if (!elementsInSet (ovrSetSets))
- fprintf (afile, "\t%s\n", port->mem.overlay_name);
+/* if (!elementsInSet (ovrSetSets))*/
+
+ /* the hack below, fixes translates for devices which
+ * only have udata_shr memory */
+ fprintf (afile, "%s\t%s\n",
+ (elementsInSet(ovrSetSets)?"":";"),
+ port->mem.overlay_name);
/* for each of the sets in the overlay segment do */
for (ovrset = setFirstItem (ovrSetSets); ovrset;
void
picglue ()
{
-
+ char udata_name[80];
FILE *vFile;
FILE *asmFile;
FILE *ovrFile = tempfile();
AnalyzepCode('*');
- //#ifdef PCODE_DEBUG
- //printCallTree(stderr);
- //#endif
+ ReuseReg(); // ReuseReg where call tree permits
InlinepCode();
fprintf (asmFile, "%s", iComments2);
copyFile (asmFile, sfr->oFile);
+
+ if (udata_section_name) {
+ sprintf(udata_name,"%s",udata_section_name);
+ } else {
+ sprintf(udata_name,"data_%s",moduleName);
+ }
fprintf (asmFile, "%s", iComments2);
fprintf (asmFile, "; udata\n");
fprintf (asmFile, "%s", iComments2);
- fprintf (asmFile, "\tudata\n");
+ fprintf (asmFile, "%s\tudata\n", udata_name);
copyFile (asmFile, data->oFile);
/* Put all variables into a cblock */
fprintf (asmFile, "%s", iComments2);
fprintf (asmFile, "; interrupt and initialization code\n");
fprintf (asmFile, "%s", iComments2);
- fprintf (asmFile, "code_init\t%s\t0x4\n", CODE_NAME);
+ fprintf (asmFile, "code_init\t%s\t0x4\n", CODE_NAME); // Note - for mplink may have to enlarge section vectors in .lnk file
/* interrupt service routine */
fprintf (asmFile, "__sdcc_interrupt:\n");