(genPlus): added special handling for 256 byte aligned xdata arrays. Erik helped...
[fw/sdcc] / src / pic / main.c
index 61485148ae29afc66af81a7498eb613555a4022e..b3515d09d77c8f1b95b14dd4db5e0eaad261a8b0 100644 (file)
@@ -9,6 +9,7 @@
 #include "ralloc.h"
 #include "device.h"
 #include "SDCCutil.h"
+#include "glue.h"
 //#include "gen.h"
 
 
@@ -239,7 +240,6 @@ _pic14_genAssemblerPreamble (FILE * of)
   }
 
   fprintf (of, "\tlist\tp=%s\n",&name[1]);
-  fprintf (of, "\t__CONFIG 0x%x\n",getConfigWord(0x2007));
   fprintf (of, "\tradix dec");
   fprintf (of, "\ninclude \"%s.inc\"\n",name);
 }
@@ -277,8 +277,10 @@ _pic14_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
 static bool
 _hasNativeMulFor (iCode *ic, sym_link *left, sym_link *right)
 {
+/*
   sym_link *test = NULL;
   value *val;
+*/
 
   fprintf(stderr,"checking for native mult\n");
 
@@ -318,6 +320,32 @@ _hasNativeMulFor (iCode *ic, sym_link *left, sym_link *right)
 */
 }
 
+/* Indicate which extended bit operations this port supports */
+static bool
+hasExtBitOp (int op, int size)
+{
+  if (op == RRC
+      || op == RLC
+      /* || op == GETHBIT */ /* GETHBIT doesn't look complete for PIC */
+     )
+    return TRUE;
+  else
+    return FALSE;
+}
+
+/* Indicate the expense of an access to an output storage class */
+static int
+oclsExpense (struct memmap *oclass)
+{
+  /* The IN_FARSPACE test is compatible with historical behaviour, */
+  /* but I don't think it is applicable to PIC. If so, please feel */
+  /* free to remove this test -- EEP */
+  if (IN_FARSPACE(oclass))
+    return 1;
+    
+  return 0;
+}
+
 /** $1 is always the basename.
     $2 is always the output file.
     $3 varies
@@ -326,16 +354,12 @@ _hasNativeMulFor (iCode *ic, sym_link *left, sym_link *right)
 */
 static const char *_linkCmd[] =
 {
-  "aslink", "-nf", "$1", NULL
+  "gplink", "", "\"$1.o\"", 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", "-c  -I /usr/local/share/gpasm/header", "$1.asm", NULL
+  "gpasm", "-c", "\"$1.asm\"", NULL
 
 };
 
@@ -345,8 +369,9 @@ PORT pic_port =
   TARGET_ID_PIC,
   "pic14",
   "MCU pic",                   /* Target name */
-  "p16f877",                    /* Processor */
+  "",                    /* Processor */
   {
+    picglue,
     TRUE,                      /* Emit glue around main */
     MODEL_SMALL | MODEL_LARGE | MODEL_FLAT24,
     MODEL_SMALL
@@ -366,14 +391,14 @@ PORT pic_port =
     _linkCmd,
     NULL,
     NULL,
-    ".rel"
+    ".o"
   },
   {
     _defaultRules
   },
   {
        /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
-    1, 2, 2, 4, 1, 2, 2, 1, 4, 4
+    1, 2, 2, 4, 2, 2, 2, 1, 4, 4
        /* TSD - I changed the size of gptr from 3 to 1. However, it should be
           2 so that we can accomodate the PIC's with 4 register banks (like the
           16f877)
@@ -382,14 +407,14 @@ PORT pic_port =
   {
     "XSEG    (XDATA)",
     "STACK   (DATA)",
-    "CSEG    (CODE)",
+    "code",
     "DSEG    (DATA)",
     "ISEG    (DATA)",
     "XSEG    (XDATA)",
     "BSEG    (BIT)",
     "RSEG    (DATA)",
     "GSINIT  (CODE)",
-    "OSEG    (OVR,DATA)",
+    "udata_ovr",
     "GSFINAL (CODE)",
     "HOME       (CODE)",
     NULL, // xidata
@@ -398,6 +423,7 @@ PORT pic_port =
     NULL,
     1        // code is read only
   },
+  { NULL, NULL },
   {
     +1, 1, 4, 1, 1, 0
   },
@@ -423,7 +449,10 @@ PORT pic_port =
   _process_pragma,                             /* process a pragma */
   NULL,
   _hasNativeMulFor,
+  hasExtBitOp,                 /* hasExtBitOp */
+  oclsExpense,                 /* oclsExpense */
   FALSE,
+  TRUE,                                /* little endian */
   0,                           /* leave lt */
   0,                           /* leave gt */
   1,                           /* transform <= to ! > */