Added -p command line option to allow selection of port dependent processor.
[fw/sdcc] / src / pic / main.c
index 346ffa9886d21930eb4e30be7abccca93edb1d24..d2693844c5d80b2f9098e354be20ab48e83956b7 100644 (file)
@@ -159,12 +159,22 @@ _pic14_getRegName (struct regs *reg)
   return "err";
 }
 
+extern char *processor_base_name(void);
+
 static void
 _pic14_genAssemblerPreamble (FILE * of)
 {
-  fprintf (of, "\tlist\tp=16f877\n");
+  char * name = processor_base_name();
+
+  if(!name) {
+
+    name = "p16f877";
+    fprintf(stderr,"WARNING: No Pic has been selected, defaulting to %s\n",name);
+  }
+
+  fprintf (of, "\tlist\tp=%s\n",&name[1]);
   fprintf (of, "\t__config _wdt_off\n");
-  fprintf (of, "\ninclude \"p16f877.inc\"\n");
+  fprintf (of, "\ninclude \"%s.inc\"\n",name);
 }
 
 /* Generate interrupt vector table. */
@@ -208,9 +218,13 @@ static const char *_linkCmd[] =
   "aslink", "-nf", "$1", NULL
 };
 
+/* Sigh. This really is not good. For now, I recommend:
+ * sdcc -S -mpic14 file.c
+ * the -S option does not compile or link
+ */
 static const char *_asmCmd[] =
 {
-  "gpasm", NULL, NULL, NULL
+  "gpasm", "-c  -I /usr/local/share/gpasm/header", "$1.asm", NULL
 
 };
 
@@ -220,6 +234,7 @@ PORT pic_port =
   TARGET_ID_PIC,
   "pic14",
   "MCU pic",                   /* Target name */
+  NULL,                         /* Processor */
   {
     TRUE,                      /* Emit glue around main */
     MODEL_SMALL | MODEL_LARGE | MODEL_FLAT24,