Oops
[fw/sdcc] / src / pic16 / glue.c
index 6b601ce4f7227d13ab96e4713128b9fb287b8b39..fac38d547d0e08f9944c828dae769c8e025dffb2 100644 (file)
@@ -29,7 +29,7 @@
 #include "newalloc.h"
 
 
-#ifdef _BIG_ENDIAN
+#ifdef WORDS_BIGENDIAN
   #define _ENDIAN(x)  (3-x)
 #else
   #define _ENDIAN(x)  (x)
@@ -86,7 +86,7 @@ int pic16aopLiteral (value *val, int offset)
 
   /* it is type float */
   fl.f = (float) floatFromVal(val);
-#ifdef _BIG_ENDIAN    
+#ifdef WORDS_BIGENDIAN
   return fl.c[3-offset];
 #else
   return fl.c[offset];
@@ -444,6 +444,7 @@ pic16emitStaticSeg (memmap * map)
       if (!IS_STATIC (sym->etype))
        addSetHead (&publics, sym);
 
+#if 0
       /* print extra debug info if required */
       if (options.debug || sym->level == 0)
        {
@@ -466,6 +467,7 @@ pic16emitStaticSeg (memmap * map)
          fprintf (code->oFile, "%s_%d_%d", sym->name, sym->level, sym->block);
 
        }
+#endif
 
       /* if it has an absolute address */
       if (SPEC_ABSA (sym->etype))
@@ -564,8 +566,14 @@ pic16createInterruptVect (FILE * vFile)
       return;
     }
 
-  fprintf (vFile, ";\t.area\t%s\n", CODE_NAME);
-  fprintf (vFile, ";__interrupt_vect:\n");
+/*
+ * update started by Vangelis Rokas on 19-Jun-2003
+ * all fprintf() calls are prefixed with ';' so they seem
+ * as comments to the assembler. I (VR) removed them */
+
+//  fprintf (vFile, "\t.area\t%s\n", CODE_NAME);
+       fprintf(vFile, "\tcode\t0x0000\n");
+  fprintf (vFile, "__interrupt_vect:\n");
 
 
   if (!port->genIVT || !(port->genIVT (vFile, interrupts, maxInterrupts)))
@@ -677,6 +685,7 @@ pic16emitOverlay (FILE * afile)
          if (IS_FUNC (sym->type))
            continue;
 
+#if 0
          /* print extra debug info if required */
          if (options.debug || sym->level == 0)
            {
@@ -696,6 +705,7 @@ pic16emitOverlay (FILE * afile)
                         (sym->localof ? sym->localof->name : "-null-"));
              fprintf (afile, "%s_%d_%d", sym->name, sym->level, sym->block);
            }
+#endif
 
          /* if is has an absolute address then generate
             an equate for this no need to allocate space */
@@ -774,7 +784,7 @@ pic16glue ()
 
   /* print the global struct definitions */
   if (options.debug)
-    cdbStructBlock (0,cdbFile);
+    cdbStructBlock (0);        //,cdbFile);
 
   vFile = tempfile();
   /* PENDING: this isnt the best place but it will do */
@@ -791,7 +801,7 @@ pic16glue ()
   pic16emitOverlay(ovrFile);
 
 
-  pic16_AnalyzepCode('*');
+       pic16_AnalyzepCode('*');
 
   //#ifdef PCODE_DEBUG
   //pic16_printCallTree(stderr);
@@ -799,7 +809,7 @@ pic16glue ()
 
   pic16_InlinepCode();
 
-  pic16_AnalyzepCode('*');
+       pic16_AnalyzepCode('*');
 
   pic16_pcode_test();
 
@@ -807,20 +817,15 @@ pic16glue ()
   /* now put it all together into the assembler file */
   /* create the assembler file name */
     
-  if (!options.c1mode) {
-    if (noAssemble && fullDstFileName)
-      {
-        sprintf (buffer, fullDstFileName);
-      }
-    else
-      {
-        sprintf (buffer, dstFileName);
-    strcat (buffer, ".asm");
-  }
-  }
-  else {
-    strcpy(buffer, options.out_name);
-  }
+  if ((noAssemble || options.c1mode)  && fullDstFileName)
+    {
+      sprintf (buffer, fullDstFileName);
+    }
+  else
+    {
+      sprintf (buffer, dstFileName);
+      strcat (buffer, ".asm");
+    }
 
   if (!(asmFile = fopen (buffer, "w"))) {
     werror (E_FILE_OPEN_ERR, buffer);
@@ -899,7 +904,10 @@ pic16glue ()
   copyFile (asmFile, bit->oFile);
 
 
-  fprintf (asmFile, "\tORG 0\n");
+/* the following is commented out. the CODE directive will be
+   used instead before code */
+   
+//  fprintf (asmFile, "\tORG 0\n");
 
   /* copy the interrupt vector table */
   if (mainf && IFFUNC_HASBODY(mainf->type)) {
@@ -923,9 +931,12 @@ pic16glue ()
   fprintf (asmFile, ";\t.area %s\n", port->mem.static_name); /* MOF */
   fprintf (asmFile, ";\t.area %s\n", port->mem.post_static_name);
   fprintf (asmFile, ";\t.area %s\n", port->mem.static_name);
-    
+
   if (mainf && IFFUNC_HASBODY(mainf->type)) {
     fprintf (asmFile,"__sdcc_gsinit_startup:\n");
+
+#if 0
+       /* 8051 legacy (?!) - VR 20-Jun-2003 */
     /* if external stack is specified then the
        higher order byte of the xdatalocation is
        going into P2 and the lower order going into
@@ -936,6 +947,7 @@ pic16glue ()
       fprintf(asmFile,";\tmov\t_spx,#0x%02x\n",
              (unsigned int)options.xdata_loc & 0xff);
     }
+#endif
 
   }
 
@@ -946,7 +958,7 @@ pic16glue ()
        * by the ugly shucking and jiving about 20 lines ago.
        */
       fprintf(asmFile, ";\t.area %s\n", port->mem.post_static_name);
-      fprintf (asmFile,";\tljmp\t__sdcc_program_startup\n");
+      fprintf (asmFile,"\tgoto\t__sdcc_program_startup\n");
     }
        
   /* copy over code */
@@ -957,17 +969,24 @@ pic16glue ()
 
   //copyFile (stderr, code->oFile);
 
-  pic16_copypCode(asmFile, 'I');
-  pic16_copypCode(asmFile, statsg->dbName);
-  pic16_copypCode(asmFile, 'X');
-  pic16_copypCode(asmFile, 'M');
-  pic16_copypCode(asmFile, code->dbName);
-  pic16_copypCode(asmFile, 'P');
+//             fprintf(asmFile, "; I code from now on!\n");
+       pic16_copypCode(asmFile, 'I');
+
+       
+//             fprintf(asmFile, "; dbName from now on!\n");
+       fprintf(asmFile, "__sdcc_program_startup:\n");
+       pic16_copypCode(asmFile, statsg->dbName);
 
+               fprintf(asmFile, "; X code from now on!\n");
+       pic16_copypCode(asmFile, 'X');
+               fprintf(asmFile, "; M code from now on!\n");
+       pic16_copypCode(asmFile, 'M');
+       pic16_copypCode(asmFile, code->dbName);
+       pic16_copypCode(asmFile, 'P');
 
-  fprintf (asmFile,"\tend\n");
+       fprintf (asmFile,"\tend\n");
 
-  fclose (asmFile);
+       fclose (asmFile);
 
-  rm_tmpfiles();
+       rm_tmpfiles();
 }