*** empty log message ***
authorvrokas <vrokas@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 26 Nov 2003 16:32:29 +0000 (16:32 +0000)
committervrokas <vrokas@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 26 Nov 2003 16:32:29 +0000 (16:32 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3029 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/SDCCmain.c
src/pic16/device.c
src/pic16/device.h
src/pic16/gen.c
src/pic16/glue.c
src/pic16/main.c
src/pic16/ralloc.c

index e9968daaed0bde6a56b9bc6e03ab6fd4237adf30..82c464396a8c8b257faecf813c95ee7572342c24 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2003-11-26 Vangelis Rokas <vrokas@otenet.gr>
+       
+       * src/pic16/main.c (_pic16_genIVT): fixed interrupt vector table
+       * src/pic16/main.c (_pic16_genAssemblerPreamble): re-enabled the
+       output of __config directives, since gpasm now supports them
+       * src/pic16/main.c (_pic16_finaliseOptions): define MCU
+       pre-processor macro, i.e. -DMCU=p18f452
+       * src/pic16/ralloc.c: renamed packRegisters to pic16_packRegisters,
+       and modified to handle 'cast' icode similarly to '=' icode
+       * src/pic16/device.h (typedef struct PIC_device): added field
+       'extMIface' to indicate that chip has external memory interface
+       * src/pic16/device.c: added chips 18F248, 18F258, 18F448, 18F458,
+       18F6520, 18F6620, 18F6680, 18F6720, 18F8520, 18F8620, 18F8680,
+       18F8720
+
 2003-11-26 Erik Petrich <epetrich@ivorytower.norman.ok.us>
 
        * src/SDCC.y (pointer): fixed bug #846006
index b3974b9fbb5eed3df5b2a65fb27a745aaa39945b..00e648de70d1a86936e3d021eceecfa57fe9f6fb 100644 (file)
@@ -289,12 +289,12 @@ static PORT *_ports[] =
 #if !OPT_DISABLE_DS390
   &ds390_port,
 #endif
-#if !OPT_DISABLE_PIC
-  &pic_port,
-#endif
 #if !OPT_DISABLE_PIC16
   &pic16_port,
 #endif
+#if !OPT_DISABLE_PIC
+  &pic_port,
+#endif
 #if !OPT_DISABLE_TININative
   &tininative_port,
 #endif
index cecd52bedf2d1d8668ecc392d6a1b667dea8e93b..23b9e81a780b47475ecaf6e0cafaeef26ba09237 100644 (file)
    Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 -------------------------------------------------------------------------*/
 
+
+/*
+       VR - Began writing code to make PIC16 C source files independent from
+       the header file (created by the inc2h.pl)
+
+       - adding maximum RAM memory into PIC_Device structure
+
+*/
+
 #include <stdio.h>
 
 #include "common.h"   // Include everything in the SDCC src directory
 
 static PIC_device Pics[] = {
   {
-    {"p18f242", "18f242", "pic18f242", "f242"},
-    (memRange *)NULL,
-    (memRange *)NULL,
+    {"p18f242", "18f242", "pic18f242", "f242"},                // aliases
+    (memRange *)NULL,                                  // ram memory map
+    (memRange *)NULL,                                  // sfr memory map
+    0,
+    0x300,                                             // bank mask
+    0x300,                                             // RAMsize
+    0
+  },
+
+  {
+    {"p18f252", "18f252", "pic18f252", "f252"},                // aliases
+    (memRange *)NULL,                                  // ram memory map
+    (memRange *)NULL,                                  // sfr memory map
+    0,
+    0x600,                                             // bank mask
+    0x600,                                             // RAMsize
+    0
+  },
+
+  {
+    {"p18f442", "18f442", "pic18f442", "f442"},                // aliases
+    (memRange *)NULL,                                  // ram memory map
+    (memRange *)NULL,                                  // sfr memory map
+    0,
+    0x300,                                             // bank mask
+    0x300,                                             // RAMsize
+    0
+  },
+
+  {
+    {"p18f452", "18f452", "pic18f452", "f452"},                // aliases
+    (memRange *)NULL,                                  // ram memory map
+    (memRange *)NULL,                                  // sfr memory map
+    0,
+    0x600,                                             // bank mask
+    0x600,                                             // RAMsize
+    0
+  },
+
+  {
+    {"p18f248", "18f248", "pic18f248", "f248"},                // aliases
+    (memRange *)NULL,                                  // ram memory map
+    (memRange *)NULL,                                  // sfr memory map
+    0,
+    0x300,                                             // bank mask
+    0x300,                                             // RAMsize
+    0
+  },
+
+  {
+    {"p18f258", "18f258", "pic18f258", "f258"},                // aliases
+    (memRange *)NULL,                                  // ram memory map
+    (memRange *)NULL,                                  // sfr memory map
+    0,
+    0x600,                                             // bank mask
+    0x600,                                             // RAMsize
+    0
+  },
+
+  {
+    {"p18f448", "18f448", "pic18f448", "f448"},                // aliases
+    (memRange *)NULL,                                  // ram memory map
+    (memRange *)NULL,                                  // sfr memory map
     0,
-    0x300,
+    0x300,                                             // bank mask
+    0x300,                                             // RAMsize
+    0
   },
 
   {
-    {"p18f252", "18f252", "pic18f252", "f252"},
-    (memRange *)NULL,
-    (memRange *)NULL,
+    {"p18f458", "18f458", "pic18f458", "f458"},                // aliases
+    (memRange *)NULL,                                  // ram memory map
+    (memRange *)NULL,                                  // sfr memory map
     0,
-    0x600,
+    0x600,                                             // bank mask
+    0x600,                                             // RAMsize
+    0
   },
 
   {
-    {"p18f442", "18f442", "pic18f442", "f442"},
-    (memRange *)NULL,
-    (memRange *)NULL,
+    {"p18f6520", "18f6520", "pic18f6520", "f6520"},    // aliases
+    (memRange *)NULL,                                  // ram memory map
+    (memRange *)NULL,                                  // sfr memory map
     0,
-    0x300,
+    0x800,                                             // bank mask
+    0x800,                                             // RAMsize
+    1
   },
 
   {
-    {"p18f452", "18f452", "pic18f452", "f452"},
-    (memRange *)NULL,
-    (memRange *)NULL,
+    {"p18f6620", "18f6620", "pic18f6620", "f6620"},    // aliases
+    (memRange *)NULL,                                  // ram memory map
+    (memRange *)NULL,                                  // sfr memory map
+    0,
+    0xf00,                                             // bank mask
+    0xf00,                                             // RAMsize
+    1
+  },
+  {
+    {"p18f6680", "18f6680", "pic18f6680", "f6680"},    // aliases
+    (memRange *)NULL,                                  // ram memory map
+    (memRange *)NULL,                                  // sfr memory map
+    0,
+    0xc00,                                             // bank mask
+    0xc00,                                             // RAMsize
+    1
+  },
+  {
+    {"p18f6720", "18f6720", "pic18f6720", "f6720"},    // aliases
+    (memRange *)NULL,                                  // ram memory map
+    (memRange *)NULL,                                  // sfr memory map
+    0,
+    0xf00,                                             // bank mask
+    0xf00,                                             // RAMsize
+    1
+  },
+  {
+    {"p18f8520", "18f8520", "pic18f8520", "f8520"},    // aliases
+    (memRange *)NULL,                                  // ram memory map
+    (memRange *)NULL,                                  // sfr memory map
+    0,
+    0x800,                                             // bank mask
+    0x800,                                             // RAMsize
+    1
+  },
+  {
+    {"p18f8620", "18f8620", "pic18f8620", "f8620"},    // aliases
+    (memRange *)NULL,                                  // ram memory map
+    (memRange *)NULL,                                  // sfr memory map
+    0,
+    0xf00,                                             // bank mask
+    0xf00,                                             // RAMsize
+    1
+  },
+  {
+    {"p18f8680", "18f8680", "pic18f8680", "f8680"},    // aliases
+    (memRange *)NULL,                                  // ram memory map
+    (memRange *)NULL,                                  // sfr memory map
+    0,
+    0xc00,                                             // bank mask
+    0x800,                                             // RAMsize
+    1
+  },
+  {
+    {"p18f8720", "18f8720", "pic18f8720", "f8720"},    // aliases
+    (memRange *)NULL,                                  // ram memory map
+    (memRange *)NULL,                                  // sfr memory map
     0,
-    0x600,
+    0xf00,                                             // bank mask
+    0xf00,                                             // RAMsize
+    1
   },
 
 };
 
 static int num_of_supported_PICS = sizeof(Pics)/sizeof(PIC_device);
 
-#define DEFAULT_PIC "f452"
+#define DEFAULT_PIC "452"
 
 static PIC_device *pic=NULL;
 
@@ -137,6 +268,9 @@ void pic16_addMemRange(memRange *r, int type)
     return;
   }
 
+//     fprintf(stderr, "%s: adding memory range from 0x%x to 0x%x type= %d\n",
+//             __FUNCTION__, r->start_address, r->end_address, type);
+
   do {
     for (i=r->start_address; i<= r->end_address; i++) {
       if ((i|alias) <= pic->maxRAMaddress) {
@@ -525,16 +659,17 @@ static int assignRegister(regs *reg, int start_address)
 {
   int i;
 
-       //fprintf(stderr,"%s -  %s start_address = 0x%03x\n",__FUNCTION__,reg->name, start_address);
+//     fprintf(stderr,"%s -  %s start_address = 0x%03x\t(max=0x%03x)\n",__FUNCTION__,reg->name, start_address, pic->maxRAMaddress);
   if(reg->isFixed) {
 
     if (validAddress(reg->address,reg->size)) {
-      //fprintf(stderr,"%s -  %s address = 0x%03x\n",__FUNCTION__,reg->name, reg->address);
+//     fprintf(stderr,"fixed %s -  %s address = 0x%03x\n",__FUNCTION__,reg->name, reg->address);
       mapRegister(reg);
       return reg->address;
     }
 
     if( isSFR(reg->address)) {
+//     fprintf(stderr,"sfr %s -  %s address = 0x%03x\n",__FUNCTION__,reg->name, reg->address);
       mapRegister(reg);
       return reg->address;
     }
index b18031759da3c10200234a762947f445e26a9ed2..ec12138bba0294993d903d4f75972bc45fff45dd 100644 (file)
@@ -90,8 +90,8 @@ typedef struct PIC_device {
 
   int maxRAMaddress;          /* maximum value for a data address */
   int bankMask;               /* Bitmask that is ANDed with address to extract banking bits */
-  //  int hasAliasedRAM:1;        /* True if there are bank independent registers */
-
+  int RAMsize;               /* size of Data RAM - VR 031120 */
+  int extMIface;               /* device has external memory interface */
 } PIC_device;
 
 /* Given a pointer to a register, this macro returns the bank that it is in */
index 367ae2842b1f4dbb3b5ae2d53e94f08c5ce06e34..c05870540fa674ba9800181c3c630a09ffe84d7d 100644 (file)
@@ -61,7 +61,6 @@ static int optimized_for_speed = 0;
   hack hack
 
 */
-int options_no_movff = 1;
 
 /* max_key keeps track of the largest label number used in 
    a function. This is then used to adjust the label offset
index ba58923f95d6d51c0d8b65c049c24308ef97878f..0c3c7f3d919c304803fecc3d64481736f5aadb82 100644 (file)
@@ -809,7 +809,7 @@ pic16glue ()
 
   pic16_InlinepCode();
 
-       pic16_AnalyzepCode('*');
+  pic16_AnalyzepCode('*');
 
   pic16_pcode_test();
 
index e1c6f24c16c78ad56277e5d32b48255f366e3578..772b6d411d1d4caf9317f73a5fb757d678170395 100644 (file)
@@ -66,6 +66,9 @@ static char *_pic16_keywords[] =
   NULL
 };
 
+
+extern char *pic16_processor_base_name(void);
+
 void  pic16_pCodeInitRegisters(void);
 
 void pic16_assignRegisters (eBBlock ** ebbs, int count);
@@ -174,9 +177,15 @@ _pic16_parseOptions (int *pargc, char **argv, int *i)
 static void
 _pic16_finaliseOptions (void)
 {
+       port->mem.default_local_map = data;
+       port->mem.default_globl_map = data;
 
-      port->mem.default_local_map = data;
-      port->mem.default_globl_map = data;
+       setMainValue("mcu", pic16_processor_base_name() );
+       addSet(&preArgvSet, Safe_strdup("-DMCU={mcu}"));
+}
+
+
+/* all the rest is commented ifdef'd out */
 #if 0
   /* Hack-o-matic: if we are using the flat24 model,
    * adjust pointer sizes.
@@ -232,7 +241,7 @@ _pic16_finaliseOptions (void)
        }
     }
 #endif
-}
+
 
 static void
 _pic16_setDefaultOptions (void)
@@ -247,7 +256,6 @@ _pic16_getRegName (struct regs *reg)
   return "err";
 }
 
-extern char *pic16_processor_base_name(void);
 
 static void
 _pic16_genAssemblerPreamble (FILE * of)
@@ -263,7 +271,6 @@ _pic16_genAssemblerPreamble (FILE * of)
   fprintf (of, "\tlist\tp=%s\n",&name[1]);
   fprintf (of, "\tinclude \"%s.inc\"\n",name);
 
-#if 0
   fprintf (of, "\t__config _CONFIG1H,0x%x\n",pic16_getConfigWord(0x300001));
   fprintf (of, "\t__config _CONFIG2L,0x%x\n",pic16_getConfigWord(0x300002));
   fprintf (of, "\t__config _CONFIG2H,0x%x\n",pic16_getConfigWord(0x300003));
@@ -275,7 +282,6 @@ _pic16_genAssemblerPreamble (FILE * of)
   fprintf (of, "\t__config _CONFIG6H,0x%x\n",pic16_getConfigWord(0x30000b));
   fprintf (of, "\t__config _CONFIG7L,0x%x\n",pic16_getConfigWord(0x30000c));
   fprintf (of, "\t__config _CONFIG7H,0x%x\n",pic16_getConfigWord(0x30000d));
-#endif
 
   fprintf (of, "\tradix dec\n");
 }
@@ -300,16 +306,16 @@ _pic16_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
 
        fprintf(of, "; RESET vector\n");
        fprintf(of, "\tgoto\t__sdcc_gsinit_startup\n");
-       fprintf(of, "\tres 6\n");
+       fprintf(of, "\tres 4\n");
 
 
        fprintf(of, "; High priority interrupt vector 0x0008\n");
        if(interrupts[1]) {
                fprintf(of, "\tgoto\t%s\n", interrupts[1]->rname);
-               fprintf(of, "\tres\t8\n");
+               fprintf(of, "\tres\t12\n"); 
        } else {
                fprintf(of, "\tretfie\n");
-               fprintf(of, "\tres\t8\n");
+               fprintf(of, "\tres\t14\n");
        }
 
        fprintf(of, "; Low priority interrupt vector 0x0018\n");
index 41de32e86ce4001abdbe2b9986b247ddc48188a0..726bb68dd58515d9b14bbaae33e0e2c4343b29db 100644 (file)
@@ -3451,12 +3451,13 @@ static void isData(sym_link *sl)
   }
     
 }
-/*-----------------------------------------------------------------*/
-/* packRegisters - does some transformations to reduce register    */
-/*                   pressure                                      */
-/*-----------------------------------------------------------------*/
+/*--------------------------------------------------------------------*/
+/* pic16_packRegisters - does some transformations to reduce          */
+/*                   register pressure                                */
+/*                                                                    */
+/*--------------------------------------------------------------------*/
 static void
-packRegisters (eBBlock * ebp)
+pic16_packRegisters (eBBlock * ebp)
 {
   iCode *ic;
   int change = 0;
@@ -3475,7 +3476,8 @@ packRegisters (eBBlock * ebp)
       {
 
        /* find assignment of the form TrueSym := iTempNN:1 */
-       if (ic->op == '=' && !POINTER_SET (ic))
+       /* see BUGLOG0001 for workaround with the CAST - VR */
+       if ((ic->op == '=' || ic->op == CAST) && !POINTER_SET (ic))
          change += packRegsForAssign (ic, ebp);
        /* debug stuff */
        if (ic->op == '=')
@@ -3825,7 +3827,7 @@ pic16_assignRegisters (eBBlock ** ebbs, int count)
   /* change assignments this will remove some
      live ranges reducing some register pressure */
   for (i = 0; i < count; i++)
-    packRegisters (ebbs[i]);
+    pic16_packRegisters (ebbs[i]);
 
   {
     regs *reg;