* src/port.h,
[fw/sdcc] / src / pic16 / main.c
index 30153b2a5a838e4c74d0f27198ef2ee66d43cb70..e1c6f24c16c78ad56277e5d32b48255f366e3578 100644 (file)
@@ -1,9 +1,29 @@
-/** @file main.c
-    pic16 specific general functions.
+/*-------------------------------------------------------------------------
+
+  main.c - pic16 specific general functions.
+
+   Written by - Scott Dattalo scott@dattalo.com
+   Ported to PIC16 by - Martin Dubuc m.debuc@rogers.com
+    
+   Note that mlh prepended _pic16_ on the static functions.  Makes
+   it easier to set a breakpoint using the debugger.
+
+
+   This program is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by the
+   Free Software Foundation; either version 2, or (at your option) any
+   later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+   
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+-------------------------------------------------------------------------*/
 
-    Note that mlh prepended _pic16_ on the static functions.  Makes
-    it easier to set a breakpoint using the debugger.
-*/
 #include "common.h"
 #include "main.h"
 #include "ralloc.h"
@@ -264,32 +284,32 @@ _pic16_genAssemblerPreamble (FILE * of)
 static int
 _pic16_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
 {
+#if 0
   int i;
+#endif
 
 #if 0
-  if (options.model != MODEL_FLAT24)
-    {
-      /* Let the default code handle it. */
-      return FALSE;
-    }
+       if (options.model != MODEL_FLAT24) {
+       /* Let the default code handle it. */
+         return FALSE;
+       }
 #endif
 
        /* PIC18F family has only two interrupts, the high and the low
-        * priority interrupts, which reside in 0x0008 and 0x0018 respectively */
+        * priority interrupts, which reside at 0x0008 and 0x0018 respectively - VR */
 
        fprintf(of, "; RESET vector\n");
        fprintf(of, "\tgoto\t__sdcc_gsinit_startup\n");
-       fprintf(of, "\tres 2\n");
+       fprintf(of, "\tres 6\n");
 
 
        fprintf(of, "; High priority interrupt vector 0x0008\n");
-       
        if(interrupts[1]) {
                fprintf(of, "\tgoto\t%s\n", interrupts[1]->rname);
-               fprintf(of, "\tres\t6\n");
+               fprintf(of, "\tres\t8\n");
        } else {
                fprintf(of, "\tretfie\n");
-               fprintf(of, "\tres\t14\n");
+               fprintf(of, "\tres\t8\n");
        }
 
        fprintf(of, "; Low priority interrupt vector 0x0018\n");
@@ -361,6 +381,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
@@ -468,7 +514,10 @@ PORT pic16_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 ! > */