src/SDCCglue.c, src/mcs51/main.c: improved implementation of --acall-ajmp
[fw/sdcc] / src / SDCCglue.c
index 7e7d3008dfd4026f95a9e65c4e8b3ab59c8d6e57..244ea51983e0392ea5947313ad4f83ea1d27b7c0 100644 (file)
@@ -747,7 +747,7 @@ printIvalStruct (symbol * sym, sym_link * type,
 
   if (SPEC_STRUCT (type)->type == UNION) {
     printIval (sym, sflds->type, iloop, oBuf);
-    iloop = iloop->next;
+    iloop = iloop ? iloop->next : NULL;
   } else {
     for (; sflds; sflds = sflds->next, iloop = (iloop ? iloop->next : NULL)) {
       if (IS_BITFIELD(sflds->type)) {
@@ -1395,7 +1395,7 @@ createInterruptVect (struct dbuf_s *vBuf)
 char *iComments1 =
 {
   ";--------------------------------------------------------\n"
-  "; File Created by SDCC : FreeWare ANSI-C Compiler\n"};
+  "; File Created by SDCC : free open source ANSI-C Compiler\n"};
 
 char *iComments2 =
 {
@@ -1411,8 +1411,9 @@ initialComments (FILE * afile)
   time_t t;
   time (&t);
   fprintf (afile, "%s", iComments1);
-  fprintf (afile, "; Version " SDCC_VERSION_STR " #%s (%s)\n", getBuildNumber(), __DATE__);
-  fprintf (afile, "; This file generated %s", asctime (localtime (&t)));
+  fprintf (afile, "; Version " SDCC_VERSION_STR " #%s (%s) (%s)\n",
+           getBuildNumber(), __DATE__, getBuildEnvironment());
+  fprintf (afile, "; This file was generated %s", asctime (localtime (&t)));
   fprintf (afile, "%s", iComments2);
 }
 
@@ -1893,10 +1894,10 @@ glue (void)
               fprintf (asmFile, "\tmov\tsp,#__start__stack - 1\n");     /* MOF */
             }
 
-          fprintf (asmFile, "\tlcall\t__sdcc_external_startup\n");
+          fprintf (asmFile, "\t%ccall\t__sdcc_external_startup\n", options.acall_ajmp?'a':'l');
           fprintf (asmFile, "\tmov\ta,dpl\n");
           fprintf (asmFile, "\tjz\t__sdcc_init_data\n");
-          fprintf (asmFile, "\tljmp\t__sdcc_program_startup\n");
+          fprintf (asmFile, "\t%cjmp\t__sdcc_program_startup\n", options.acall_ajmp?'a':'l');
           fprintf (asmFile, "__sdcc_init_data:\n");
 
           // if the port can copy the XINIT segment to XISEG
@@ -1915,7 +1916,7 @@ glue (void)
        * by the ugly shucking and jiving about 20 lines ago.
        */
       tfprintf (asmFile, "\t!area\n", port->mem.post_static_name);
-      fprintf (asmFile, "\tljmp\t__sdcc_program_startup\n");
+      fprintf (asmFile, "\t%cjmp\t__sdcc_program_startup\n", options.acall_ajmp?'a':'l');
     }
 
   fprintf (asmFile,
@@ -1933,12 +1934,12 @@ glue (void)
       /* put in jump or call to main */
       if (options.mainreturn)
         {
-          fprintf (asmFile, "\tljmp\t_main\n");   /* needed? */
+          fprintf (asmFile, "\t%cjmp\t_main\n", options.acall_ajmp?'a':'l');   /* needed? */
           fprintf (asmFile, ";\treturn from main will return to caller\n");
         }
       else
         {
-          fprintf (asmFile, "\tlcall\t_main\n");
+          fprintf (asmFile, "\t%ccall\t_main\n", options.acall_ajmp?'a':'l');
           fprintf (asmFile, ";\treturn from main will lock up\n");
           fprintf (asmFile, "\tsjmp .\n");
         }