fixed bug 663530
[fw/sdcc] / src / SDCCglue.c
index 17ebae4660b069ec9f4ace0fccab76512626d65f..b1b6577f9359dc5ed338f8c2e0e1b0026ad907e7 100644 (file)
@@ -1229,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;
     }
@@ -1458,14 +1458,15 @@ glue (void)
   /* 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")))
@@ -1505,19 +1506,22 @@ glue (void)
   copyFile (asmFile, sfrbit->oFile);
   
   /*JCF: Create the areas for the register banks*/
-  if(RegBankUsed[0]||RegBankUsed[1]||RegBankUsed[2]||RegBankUsed[3])
+  if( TARGET_IS_MCS51 || TARGET_IS_DS390 || TARGET_IS_XA51 )
   {
-     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");
+         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 */
@@ -1622,7 +1626,7 @@ glue (void)
        }
 
       /* initialise the stack pointer.  JCF: aslink takes care of the location */
-       fprintf (asmFile, "\tmov\tsp,#__start__stack\n");       /* MOF */
+       fprintf (asmFile, "\tmov\tsp,#__start__stack - 1\n");   /* MOF */
 
       fprintf (asmFile, "\tlcall\t__sdcc_external_startup\n");
       fprintf (asmFile, "\tmov\ta,dpl\n");