X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2FSDCCglue.c;h=59f82998c0ae74494db1f6ab87f58f442fff2a36;hb=488567416a6098132fb90a0bcd226e466bfc5b22;hp=590320ca0684bebc60635cac9402b98185abe740;hpb=3116970475b5a22f0f35dec513a56abfdd73e697;p=fw%2Fsdcc diff --git a/src/SDCCglue.c b/src/SDCCglue.c index 590320ca..59f82998 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -60,7 +60,7 @@ DEFSETFUNC (closeTmpFiles) } /*-----------------------------------------------------------------*/ -/* rmTmpFiles - closes all tmp files created by the compiler */ +/* rmTmpFiles - unlinks all tmp files created by the compiler */ /* because of BRAIN DEAD MS/DOS & CYGNUS Libraries */ /*-----------------------------------------------------------------*/ DEFSETFUNC (rmTmpFiles) @@ -75,6 +75,21 @@ DEFSETFUNC (rmTmpFiles) return 0; } +/*-----------------------------------------------------------------*/ +/* rm_tmpfiles - close and remove temporary files and delete sets */ +/*-----------------------------------------------------------------*/ +void +rm_tmpfiles (void) +{ + /* close temporary files */ + applyToSet (tmpfileSet, closeTmpFiles); + /* remove temporary files */ + applyToSet (tmpfileNameSet, rmTmpFiles); + /* delete temorary file sets */ + deleteSet (&tmpfileSet); + deleteSet (&tmpfileNameSet); +} + /*-----------------------------------------------------------------*/ /* copyFile - copies source file to destination file */ /*-----------------------------------------------------------------*/ @@ -734,12 +749,13 @@ printIvalChar (sym_link * type, initList * ilist, FILE * oFile, char *s) /*-----------------------------------------------------------------*/ /* printIvalArray - generates code for array initialization */ /*-----------------------------------------------------------------*/ -void +void printIvalArray (symbol * sym, sym_link * type, initList * ilist, FILE * oFile) { initList *iloop; int lcnt = 0, size = 0; + sym_link *last_type; /* take care of the special case */ /* array of characters can be init */ @@ -763,6 +779,8 @@ printIvalArray (symbol * sym, sym_link * type, initList * ilist, iloop = ilist->init.deep; lcnt = DCL_ELEM (type); + for (last_type = type->next; last_type && DCL_ELEM (last_type); last_type = last_type->next) + lcnt *= DCL_ELEM (last_type); for (;;) { @@ -1162,7 +1180,7 @@ emitStaticSeg (memmap * map, FILE * out) /* emitMaps - emits the code for the data portion the code */ /*-----------------------------------------------------------------*/ void -emitMaps () +emitMaps (void) { inInitMode++; /* no special considerations for the following @@ -1211,7 +1229,7 @@ createInterruptVect (FILE * vFile) /* only if the main function exists */ if (!(mainf = findSymWithLevel (SymbolTab, mainf))) { - if (!options.cc_only && !noAssemble) + if (!options.cc_only && !noAssemble && !options.c1mode) werror (E_NO_MAIN); return; } @@ -1411,7 +1429,7 @@ emitOverlay (FILE * afile) /* glue - the final glue that hold the whole thing together */ /*-----------------------------------------------------------------*/ void -glue () +glue (void) { FILE *vFile; FILE *asmFile; @@ -1440,14 +1458,15 @@ glue () /* now put it all together into the assembler file */ /* create the assembler file name */ - if (!options.c1mode) + /* -o option overrides default name? */ + if ((noAssemble || options.c1mode) && fullDstFileName) { - sprintf (scratchFileName, srcFileName); - strcat (scratchFileName, port->assembler.file_ext); + strcpy (scratchFileName, fullDstFileName); } else { - strcpy (scratchFileName, options.out_name); + strcpy (scratchFileName, dstFileName); + strcat (scratchFileName, port->assembler.file_ext); } if (!(asmFile = fopen (scratchFileName, "w"))) @@ -1485,6 +1504,26 @@ glue () fprintf (asmFile, "; special function bits \n"); fprintf (asmFile, "%s", iComments2); copyFile (asmFile, sfrbit->oFile); + + /*JCF: Create the areas for the register banks*/ + if(port->general.glue_up_main && + (TARGET_IS_MCS51 || TARGET_IS_DS390 || TARGET_IS_XA51)) + { + if(RegBankUsed[0]||RegBankUsed[1]||RegBankUsed[2]||RegBankUsed[3]) + { + fprintf (asmFile, "%s", iComments2); + fprintf (asmFile, "; overlayable register banks \n"); + fprintf (asmFile, "%s", iComments2); + if(RegBankUsed[0]) + fprintf (asmFile, "\t.area REG_BANK_0\t(REL,OVR,DATA)\n\t.ds 8\n"); + if(RegBankUsed[1]||options.parms_in_bank1) + fprintf (asmFile, "\t.area REG_BANK_1\t(REL,OVR,DATA)\n\t.ds 8\n"); + if(RegBankUsed[2]) + fprintf (asmFile, "\t.area REG_BANK_2\t(REL,OVR,DATA)\n\t.ds 8\n"); + if(RegBankUsed[3]) + fprintf (asmFile, "\t.area REG_BANK_3\t(REL,OVR,DATA)\n\t.ds 8\n"); + } + } /* copy the data segment */ fprintf (asmFile, "%s", iComments2); @@ -1587,16 +1626,8 @@ glue () (unsigned int) options.xdata_loc & 0xff); } - /* initialise the stack pointer */ - /* if the user specified a value then use it */ - if (options.stack_loc) - fprintf (asmFile, "\tmov\tsp,#%d\n", options.stack_loc & 0xff); - else - /* no: we have to compute it */ - if (!options.stackOnData && maxRegBank <= 3) - fprintf (asmFile, "\tmov\tsp,#%d\n", ((maxRegBank + 1) * 8) - 1); - else - fprintf (asmFile, "\tmov\tsp,#__start__stack\n"); /* MOF */ + /* initialise the stack pointer. JCF: aslink takes care of the location */ + fprintf (asmFile, "\tmov\tsp,#__start__stack - 1\n"); /* MOF */ fprintf (asmFile, "\tlcall\t__sdcc_external_startup\n"); fprintf (asmFile, "\tmov\ta,dpl\n"); @@ -1662,18 +1693,9 @@ glue () port->genAssemblerEnd(asmFile); } fclose (asmFile); - applyToSet (tmpfileSet, closeTmpFiles); - applyToSet (tmpfileNameSet, rmTmpFiles); -} -#if defined (__MINGW32__) || defined (__CYGWIN__) || defined (_MSC_VER) -void -rm_tmpfiles (void) -{ - applyToSet (tmpfileSet, closeTmpFiles); - applyToSet (tmpfileNameSet, rmTmpFiles); + rm_tmpfiles (); } -#endif /** Creates a temporary file name a'la tmpnam which avoids the bugs in cygwin wrt c:\tmp.