Added -p command line option to allow selection of port dependent processor.
authorsdattalo <sdattalo@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 20 Mar 2002 06:10:31 +0000 (06:10 +0000)
committersdattalo <sdattalo@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 20 Mar 2002 06:10:31 +0000 (06:10 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2001 4a8a32a2-be11-0410-ad9d-d568d2c75423

18 files changed:
src/SDCCmain.c
src/avr/main.c
src/ds390/main.c
src/izt/i186.c
src/izt/tlcs900h.c
src/mcs51/main.c
src/pic/device.c
src/pic/gen.c
src/pic/glue.c
src/pic/main.c
src/pic/pcode.c
src/pic/pcode.h
src/pic/pcodepeep.c
src/pic/peeph.def
src/pic/ralloc.c
src/port.h
src/xa51/main.c
src/z80/main.c

index 6bf1381fe25bd110a15fcd49ef6e71e59f7874a8..fa2883d36e1f5f130f4d7ec6e7d6c443e61f851b 100644 (file)
@@ -138,6 +138,7 @@ typedef struct {
 static const OPTION 
 optionsTable[] = {
     { 'm',  NULL,                   NULL, "Set the port to use e.g. -mz80." },
+    { 'p',  NULL,                   NULL, "Select port specific processor e.g. -mpic14 -p16f84" },
     { 'd',  NULL,                   NULL, NULL },
     { 'D',  NULL,                   NULL, "Define macro as in -Dmacro" },
     { 'I',  NULL,                   NULL, "Add to the include (*.h) path, as in -Ipath" },
@@ -235,8 +236,6 @@ unsupportedOptTable[] = {
     { 'g',  NULL,      "use --generic instead" },
     { 'X',  NULL,      "use --xstack-loc instead" },
     { 'x',  NULL,      "use --xstack instead" },
-    { 'p',  NULL,      "use --stack-loc instead" },
-    { 'P',  NULL,      "use --stack-loc instead" },
     { 'i',  NULL,      "use --idata-loc instead" },
     { 'r',  NULL,      "use --xdata-loc instead" },
     { 's',  NULL,      "use --code-loc instead" },
@@ -293,10 +292,9 @@ static PORT *_ports[] =
 
 #define NUM_PORTS (sizeof(_ports)/sizeof(_ports[0]))
 
-/**
-   remove me - TSD a hack to force sdcc to generate gpasm format .asm files.
- */
+#if !OPT_DISABLE_PIC
 extern void picglue ();
+#endif
 
 /** Sets the port to the one given by the command line option.
     @param    The name minus the option (eg 'mcs51')
@@ -327,11 +325,16 @@ _validatePorts (void)
     {
       if (_ports[i]->magic != PORT_MAGIC)
        {
+         /* Uncomment this line to debug which port is causing the problem
+          * (the target name is close to the beginning of the port struct 
+          * and probably can be accessed just fine). */
+         fprintf(stderr,"%s :",_ports[i]->target);
          wassertl (0, "Port definition structure is incomplete");
        }
     }
 }
 
+/* search through the command line options for the port */
 static void
 _findPort (int argc, char **argv)
 {
@@ -599,6 +602,13 @@ _setModel (int model, const char *sz)
     werror (W_UNSUPPORTED_MODEL, sz, port->target);
 }
 
+static void
+_setProcessor (char *_processor)
+{
+  port->processor = _processor;
+  fprintf(stderr,"Processor: %s\n",_processor);
+}
+
 /** Gets the string argument to this option.  If the option is '--opt'
     then for input of '--optxyz' or '--opt xyz' returns xyz.
 */
@@ -947,6 +957,11 @@ parseCmdLine (int argc, char **argv)
              _setPort (argv[i] + 2);
              break;
 
+           case 'p':
+             /* Used to select the processor in port */
+             _setProcessor (getStringArg("-p", argv, &i, argc));
+             break;
+
            case 'c':
               verifyShortOption(argv[i]);
 
@@ -1167,11 +1182,13 @@ linkEdit (char **envp)
        }
 #endif
 
-#if !OPT_DISABLE_XA51
+#if !OPT_DISABLE_XA51 
+#ifdef STD_XA51_LIB
       if (options.model == MODEL_PAGE0)
        {
          fprintf (lnkfile, "-l %s\n", STD_XA51_LIB);
        }
+#endif
 #endif
       fprintf (lnkfile, "-l %s\n", STD_LIB);
       fprintf (lnkfile, "-l %s\n", STD_INT_LIB);
index d073f5072e926bf7bf1972de27e725254720fea7..05b779847e3d6fb206f6fdd9e469133fefecb858 100644 (file)
@@ -151,6 +151,7 @@ PORT avr_port = {
         TARGET_ID_AVR,
        "avr",
        "ATMEL AVR",            /* Target name */
+       NULL,                   /* processor */
        {
         TRUE,                  /* Emit glue around main */
         MODEL_LARGE | MODEL_SMALL,
index 4e112d6b345bbe7573e8fe86f0670cf2dcbc3afa..57444c80ce79c20ad1d95c2b29aa78d5a87d06bc 100644 (file)
@@ -324,6 +324,7 @@ PORT ds390_port =
   TARGET_ID_DS390,
   "ds390",
   "DS80C390",                  /* Target name */
+  NULL,
   {
     TRUE,                      /* Emit glue around main */
     MODEL_SMALL | MODEL_LARGE | MODEL_FLAT24,
@@ -607,6 +608,7 @@ PORT tininative_port =
   TARGET_ID_DS390,
   "TININative",
   "DS80C390",                  /* Target name */
+       NULL,                   /* processor */
   {
     FALSE,                     /* Emit glue around main */
     MODEL_FLAT24,
index e01ebe4d174ac8e2fc474e40642cad5f1bf78b24..60048a43888f726333c6b12edadca16e656d51a4 100644 (file)
@@ -136,6 +136,7 @@ PORT i186_port = {
     TARGET_ID_I186,
     "i186",
     "Intel 80186",      /* Target name */
+    NULL,
     {
         FALSE,          /* Emit glue around main */
         MODEL_SMALL,
index 48a854f1a12dd0aeffff9098ab52ca5beda9626b..2f5a9d226002f22a42821a4070ce32e14f32a2f2 100644 (file)
@@ -135,6 +135,7 @@ PORT tlcs900h_port =
   TARGET_ID_TLCS900H,
   "tlcs900h",
   "Toshiba TLCS-900H",         /* Target name */
+  NULL,
   {
     TRUE,                      /* Emit glue around main */
     MODEL_SMALL,
index bad1b313e3fc7bebe21fa477999751ea6c4cc1ef..b30973748e314907b7cb358d29230d01ea3a8eea 100644 (file)
@@ -227,6 +227,7 @@ PORT mcs51_port =
   TARGET_ID_MCS51,
   "mcs51",
   "MCU 8051",                  /* Target name */
+  NULL,                                /* Processor name */
   {
     TRUE,                      /* Emit glue around main */
     MODEL_SMALL | MODEL_LARGE,
index 87004950deaea76d51270eae2557bf0439a4480c..a7d546f46b03f49b7b8f47a8329d469005ba1029 100644 (file)
@@ -48,6 +48,7 @@ memRange p16f627_sfr[] = {
   {0x02,  0x04,  0x180, 0},
   {0x05,  0x05,  0x000, 0},
   {0x06,  0x06,  0x100, 0},
+  {0x81,  0x81,  0x100, 1},
   {0x85,  0x85,  0x000, 1},
   {0x86,  0x86,  0x100, 1},
   {0x0a,  0x0b,  0x180, 0},
@@ -72,7 +73,8 @@ memRange p16f84_sfr[] = {
   {0x01,  0x01,  0x00, 0},
   {0x02,  0x04,  0x80, 0},
   {0x05,  0x06,  0x00, 0},
-  {0x85,  0x86,  0x80, 1},
+  {0x81,  0x81,  0x00, 1},
+  {0x85,  0x86,  0x00, 1},
   {0x08,  0x09,  0x00, 0},
   {0x88,  0x89,  0x00, 1},
   {0x0a,  0x0b,  0x80, 0},
@@ -94,6 +96,7 @@ memRange p16f877_sfr[] = {
   {0x02,  0x04,  0x180, 0},
   {0x05,  0x05,  0x000, 0},
   {0x85,  0x85,  0x000, 1},
+  {0x81,  0x81,  0x100, 1},
   {0x06,  0x06,  0x100, 0},
   {0x86,  0x86,  0x100, 1},
   {0x07,  0x09,  0x000, 0},
@@ -144,7 +147,7 @@ static PIC_device Pics[] = {
 
 static int num_of_supported_PICS = sizeof(Pics)/sizeof(PIC_device);
 static int default_pic = 0;
-#define DEFAULT_PIC "f84"
+#define DEFAULT_PIC "f877"
 
 static PIC_device *pic=NULL;
 
@@ -463,7 +466,7 @@ void mapRegister(regs *reg)
 
     do {
 
-      fprintf(stdout,"mapping %s to address 0x%02x\n",reg->name, (reg->address+alias+i));
+      //fprintf(stdout,"mapping %s to address 0x%02x\n",reg->name, (reg->address+alias+i));
 
       finalMapping[reg->address + alias + i].reg = reg;
       finalMapping[reg->address + alias + i].instance = i;
@@ -535,7 +538,7 @@ void assignFixedRegisters(set *regset)
 
 }
 
-void assignRelocatableRegisters(set *regset)
+void assignRelocatableRegisters(set *regset, int used)
 {
 
   regs *reg;
@@ -546,7 +549,7 @@ void assignRelocatableRegisters(set *regset)
 
     //fprintf(stdout,"assigning %s\n",reg->name);
 
-    if(!reg->isFixed) 
+    if((!reg->isFixed) && ( (used==0) || reg->wasUsed))
       address = assignRegister(reg,address);
 
   }
index 0bf3c7b11155e7b40a1b492d25d820c5404a986e..08537ea7a49596c7fedd74a1540b0d1bc211649b 100644 (file)
@@ -1678,10 +1678,14 @@ static void genNot (iCode *ic)
   DEBUGpic14_AopType(__LINE__,IC_LEFT(ic),NULL,IC_RESULT(ic));
   /* if in bit space then a special case */
   if (AOP_TYPE(IC_LEFT(ic)) == AOP_CRY) {
-    pic14_emitcode("movlw","1<<garbage");
-    //pic14_emitcode("mov","c,%s",IC_LEFT(ic)->aop->aopu.aop_dir); 
-    //pic14_emitcode("cpl","c"); 
-    //pic14_outBitC(IC_RESULT(ic));
+    if (AOP_TYPE(IC_RESULT(ic)) == AOP_CRY) {
+      emitpcode(POC_MOVLW,popGet(AOP(IC_LEFT(ic)),0));
+      emitpcode(POC_XORWF,popGet(AOP(IC_RESULT(ic)),0));
+    } else {
+      emitpcode(POC_CLRF,popGet(AOP(IC_RESULT(ic)),0));
+      emitpcode(POC_BTFSS,popGet(AOP(IC_LEFT(ic)),0));
+      emitpcode(POC_INCF,popGet(AOP(IC_RESULT(ic)),0));
+    }
     goto release;
   }
 
@@ -4458,6 +4462,19 @@ static void genCmpEq (iCode *ic, iCode *ifx)
                 pic14_emitcode("ljmp","%05d_DS_",IC_FALSE(ifx)->key+100);
             }
             pic14_emitcode("","%05d_DS_:",tlbl->key+100+labelOffset);
+
+           {
+             /* left and right are both bit variables, result is carry */
+             resolvedIfx rIfx;
+             
+             resolveIfx(&rIfx,ifx);
+
+             emitpcode(POC_MOVLW,popGet(AOP(left),0));
+             emitpcode(POC_ANDFW,popGet(AOP(left),0));
+             emitpcode(POC_BTFSC,popGet(AOP(right),0));
+             emitpcode(POC_ANDLW,popGet(AOP(left),0));
+             genSkipz2(&rIfx);
+           }
         } else {
 
          /* They're not both bit variables. Is the right a literal? */
index c48be2671adbefb54b0537d6812b7ed8ead88d92..d467d81685442dee17fd77d14622ef3598ecae72 100644 (file)
@@ -860,7 +860,7 @@ picglue ()
   AnalyzepCode('*'); //code->dbName);
 
   //#ifdef PCODE_DEBUG
-  printCallTree(stderr);
+  //  printCallTree(stderr);
   //#endif
 
   pcode_test();
index 96ae3b39c83261f62220f279c2b27ada7fb9e2bb..d2693844c5d80b2f9098e354be20ab48e83956b7 100644 (file)
@@ -234,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,
index f2177942d87b22a6137d0572d0835d63bbbfcfad..98113546925ab81ebc03b6726a50958fa15eb767 100644 (file)
@@ -45,8 +45,8 @@ pCodeOpReg pc_pcl       = {{PO_PCL,     "PCL"}, -1, NULL,0,NULL};
 pCodeOpReg pc_pclath    = {{PO_PCLATH,  "PCLATH"}, -1, NULL,0,NULL};
 
 pCodeOpReg pc_kzero     = {{PO_GPR_REGISTER,  "KZ"}, -1, NULL,0,NULL};
-pCodeOpReg pc_wsave     = {{PO_GPR_REGISTER,  "W_SAVE"}, -1, NULL,0,NULL};
-pCodeOpReg pc_ssave     = {{PO_GPR_REGISTER,  "STATUS_SAVE"}, -1, NULL,0,NULL};
+pCodeOpReg pc_wsave     = {{PO_GPR_REGISTER,  "WSAVE"}, -1, NULL,0,NULL};
+pCodeOpReg pc_ssave     = {{PO_GPR_REGISTER,  "SSAVE"}, -1, NULL,0,NULL};
 
 static int mnemonics_initialized = 0;
 
@@ -56,7 +56,7 @@ static hTab *pic14MnemonicsHash = NULL;
 
 
 static pFile *the_pFile = NULL;
-static int peepOptimizing = 0;
+static int peepOptimizing = 1;
 static int GpCodeSequenceNumber = 1;
 static int GpcFlowSeq = 1;
 
index c0a8bee399914a06996926f88bb28f1a164cdb73..8a8df94f63ca552140e0bc5ca3527a6603ffacb1 100644 (file)
@@ -76,7 +76,7 @@ struct regs;
  * The double parenthesis (()) are necessary
  * 
  ***********************************************************************/
-//#define PCODE_DEBUG
+#define PCODE_DEBUG
 
 #ifdef PCODE_DEBUG
 #define DFPRINTF(args) (fprintf args)
index fe125973d1dcba26e20eceaac6d6495496d8b91b..8e7dcdb48697467a8a1c8dcd3ec385fc0c86648f 100644 (file)
@@ -1529,9 +1529,17 @@ static pCodeOp *pCodeOpCopy(pCodeOp *pcop)
     PCOL(pcopnew)->lit = PCOL(pcop)->lit;
     break;
 
+  case PO_GPR_BIT:
+
+    pcopnew = newpCodeOpBit(pcop->name, PCORB(pcop)->bit,PCORB(pcop)->inBitSpace);
+    PCOR(pcopnew)->r = PCOR(pcop)->r;
+    PCOR(pcopnew)->rIdx = PCOR(pcop)->rIdx;
+    DFPRINTF((stderr," pCodeOpCopy Bit -register index\n"));
+    return pcopnew;
+    break;
+
   case PO_GPR_REGISTER:
   case PO_GPR_TEMP:
-  case PO_GPR_BIT:
   case PO_FSR:
   case PO_INDF:
     //DFPRINTF((stderr,"pCodeOpCopy GPR register\n"));
@@ -1541,6 +1549,8 @@ static pCodeOp *pCodeOpCopy(pCodeOp *pcop)
     DFPRINTF((stderr," register index %d\n", PCOR(pcop)->r->rIdx));
     break;
 
+  case PO_STATUS:
+    DFPRINTF((stderr,"pCodeOpCopy PO_STATUS\n"));
   case PO_DIR:
     //DFPRINTF((stderr,"pCodeOpCopy PO_DIR\n"));
   case PO_SFR_REGISTER:
@@ -1548,7 +1558,6 @@ static pCodeOp *pCodeOpCopy(pCodeOp *pcop)
   case PO_NONE:
   case PO_W:
   case PO_INTCON:
-  case PO_STATUS:
   case PO_PCL:
   case PO_PCLATH:
 
index d6a80a0e98c17d71c130ef1b786c23edbe24353e..bb586cc77f850454b5028a1d952410f8280b1fba 100644 (file)
@@ -36,9 +36,9 @@
 //    clrw
 //lab1
 //
-// However, the Rule has wild cards four wild cards.
-// The first allows the btfss instruction operate
-// on anything, not just the Z bit in status register.
+// However, the Rule has four wild cards.
+// The first allows the btfss instruction operator
+// be anything, not just the Z bit in status register.
 // The second wild card applies to a label.
 // The third wild card is for an instruction - any
 // single instruction can be substituted.
index 7b7f125b14b2545c692498869aebde04d0c1b889..19faff94cf36e412d1351b4eb4a3bd83f5562054 100644 (file)
@@ -760,6 +760,8 @@ pic14_allocWithIdx (int idx)
     debugLog ("Found a Stack Register!\n");
   } else if( (dReg = regWithIdx ( dynProcessorRegs, idx,0)) != NULL ) {
     debugLog ("Found a Processor Register!\n");
+  } else if( (dReg = regWithIdx ( dynInternalRegs, idx,0)) != NULL ) {
+    debugLog ("Found an Internal Register!\n");
   } else {
     
     debugLog ("Dynamic Register not found\n");
@@ -871,7 +873,7 @@ void writeSetUsedRegs(FILE *of, set *dRegs)
 
 }
 extern void assignFixedRegisters(set *regset);
-extern void assignRelocatableRegisters(set *regset);
+extern void assignRelocatableRegisters(set *regset,int used);
 extern void dump_map(void);
 extern void dump_cblock(FILE *of);
 
@@ -993,9 +995,10 @@ void writeUsedRegs(FILE *of)
   assignFixedRegisters(dynStackRegs);
   assignFixedRegisters(dynDirectRegs);
 
-  assignRelocatableRegisters(dynAllocRegs);
-  assignRelocatableRegisters(dynStackRegs);
-  assignRelocatableRegisters(dynDirectRegs);
+  assignRelocatableRegisters(dynInternalRegs,1);
+  assignRelocatableRegisters(dynAllocRegs,0);
+  assignRelocatableRegisters(dynStackRegs,0);
+  assignRelocatableRegisters(dynDirectRegs,0);
 
   //dump_map();
 
index 672a701b3b89e86f36b791adaa83166564554101..04b02102c2d17f9a60933d43eedf363f543571f0 100644 (file)
@@ -51,6 +51,9 @@ typedef struct
 /** Target name string, used for --help */
     const char *target_name;
 
+/** Specific processor for the given target family. specified by -p */
+    char *processor;
+
     struct
       {
        /** TRUE if all types of glue functions should be inserted into
index eb2c944f840bafa853e95454d38ec796d67b461d..077af218162249492f9414b1bab44d46ff56567c 100755 (executable)
@@ -209,6 +209,7 @@ PORT xa51_port =
   TARGET_ID_XA51,
   "xa51",
   "MCU 80C51XA",                       /* Target name */
+  NULL,                                /* Processor name */
   {
     FALSE,                     /* Emit glue around main */
     MODEL_PAGE0,
index 06cc6c1fbe905cc00edeb92623ac96acf6bac001..81c9a80b9c76850171806b6d4a0e10bb065aeeea 100644 (file)
@@ -455,6 +455,7 @@ PORT z80_port =
   TARGET_ID_Z80,
   "z80",
   "Zilog Z80",                 /* Target name */
+  NULL,                                /* Processor name */
   {
     FALSE,
     MODEL_MEDIUM | MODEL_SMALL,
@@ -546,6 +547,7 @@ PORT gbz80_port =
   TARGET_ID_GBZ80,
   "gbz80",
   "Gameboy Z80-like",          /* Target name */
+  NULL,
   {
     FALSE,
     MODEL_MEDIUM | MODEL_SMALL,