* src/SDCCmain.c, src/ds390/main.c, src/mcs51/main.c, src/pic/main.c,
authorborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 10 Jun 2007 16:47:35 +0000 (16:47 +0000)
committerborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 10 Jun 2007 16:47:35 +0000 (16:47 +0000)
  src/z80/main.c: move target specific options from src/SDCCmain.c
  to src/<target>/main.c

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4845 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/SDCCmain.c
src/ds390/main.c
src/mcs51/main.c
src/pic/main.c
src/z80/main.c

index 996cf6cc2596eeefa2572dfc711d0c0c96aafe90..5edeabf8afec029ac6a4dfc852c206da58b042c0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,9 @@
 
        * as/link/z80/lklibr.c: fixed mingw build warning
          lklibr.c:575: warning: implicit declaration of function 'tolower'
+       * src/SDCCmain.c, src/ds390/main.c, src/mcs51/main.c, src/pic/main.c,
+         src/z80/main.c: move target specific options from src/SDCCmain.c
+         to src/<target>/main.c
 
 2007-06-09 Borut Razem <borut.razem AT siol.net>
 
index f4c21bf1b66312eeceab11718d8c49d3b235b99f..51218ee797baa4f2c7d08974784cbfc3c58ccb69 100644 (file)
@@ -96,13 +96,11 @@ char buffer[PATH_MAX * 2];
 #define LENGTH(_a)      (sizeof(_a)/sizeof(*(_a)))
 
 #define OPTION_HELP             "--help"
-#define OPTION_STACK_8BIT       "--stack-8bit"
 #define OPTION_OUT_FMT_IHX      "--out-fmt-ihx"
 #define OPTION_OUT_FMT_S19      "--out-fmt-s19"
 #define OPTION_LARGE_MODEL      "--model-large"
 #define OPTION_MEDIUM_MODEL     "--model-medium"
 #define OPTION_SMALL_MODEL      "--model-small"
-#define OPTION_FLAT24_MODEL     "--model-flat24"
 #define OPTION_DUMP_ALL         "--dumpall"
 #define OPTION_PEEP_FILE        "--peep-file"
 #define OPTION_LIB_PATH         "--lib-path"
@@ -113,7 +111,6 @@ char buffer[PATH_MAX * 2];
 #define OPTION_IDATA_LOC        "--idata-loc"
 #define OPTION_XRAM_LOC         "--xram-loc"
 #define OPTION_CODE_LOC         "--code-loc"
-#define OPTION_STACK_SIZE       "--stack-size"
 #define OPTION_IRAM_SIZE        "--iram-size"
 #define OPTION_XRAM_SIZE        "--xram-size"
 #define OPTION_CODE_SIZE        "--code-size"
@@ -125,15 +122,12 @@ char buffer[PATH_MAX * 2];
 #define OPTION_DISABLE_WARNING  "--disable-warning"
 #define OPTION_NO_GCSE          "--nogcse"
 #define OPTION_SHORT_IS_8BITS   "--short-is-8bits"
-#define OPTION_TINI_LIBID       "--tini-libid"
 #define OPTION_NO_XINIT_OPT     "--no-xinit-opt"
 #define OPTION_NO_CCODE_IN_ASM  "--no-c-code-in-asm"
 #define OPTION_ICODE_IN_ASM     "--i-code-in-asm"
 #define OPTION_PRINT_SEARCH_DIRS "--print-search-dirs"
 #define OPTION_MSVC_ERROR_STYLE "--vc"
 #define OPTION_USE_STDOUT       "--use-stdout"
-#define OPTION_PACK_IRAM        "--pack-iram"
-#define OPTION_NO_PACK_IRAM     "--no-pack-iram"
 #define OPTION_NO_PEEP_COMMENTS "--no-peep-comments"
 #define OPTION_VERBOSE_ASM      "--fverbose-asm"
 #define OPTION_OPT_CODE_SPEED   "--opt-code-speed"
@@ -189,11 +183,6 @@ optionsTable[] = {
     { 0,    OPTION_LARGE_MODEL,     NULL, "external data space is used" },
     { 0,    OPTION_MEDIUM_MODEL,    NULL, "external paged data space is used" },
     { 0,    OPTION_SMALL_MODEL,     NULL, "internal data space is used (default)" },
-#if !OPT_DISABLE_DS390
-    { 0,    OPTION_FLAT24_MODEL,    NULL, "use the flat24 model for the ds390 (default)" },
-    { 0,    OPTION_STACK_8BIT,      NULL, "use the 8bit stack for the ds390 (not supported yet)" },
-    { 0,    "--stack-10bit",        &options.stack10bit, "use the 10bit stack for ds390 (default)" },
-#endif
     { 0,    "--stack-auto",         &options.stackAuto, "Stack automatic variables" },
     { 0,    "--xstack",             &options.useXstack, "Use external stack" },
     { 0,    "--int-long-reent",     &options.intlong_rent, "Use reenterant calls on the int and long support functions" },
@@ -204,26 +193,11 @@ optionsTable[] = {
     { 0,    "--profile",            &options.profile, "On supported ports, generate extra profiling information" },
     { 0,    "--fommit-frame-pointer", &options.ommitFramePtr, "Leave out the frame pointer." },
     { 0,    "--all-callee-saves",   &options.all_callee_saves, "callee will always save registers used" },
-#if !OPT_DISABLE_DS390
-    { 0,    "--use-accelerator",    &options.useAccelerator,"generate code for  DS390 Arithmetic Accelerator"},
-#endif
     { 0,    "--stack-probe",        &options.stack_probe,"insert call to function __stack_probe at each function prologue"},
-#if !OPT_DISABLE_TININative
-    { 0,    "--tini-libid",         NULL,"<nnnn> LibraryID used in -mTININative"},
-#endif
-#if !OPT_DISABLE_DS390
-    { 0,    "--protect-sp-update",  &options.protect_sp_update,"DS390 - will disable interrupts during ESP:SP updates"},
-#endif
-#if !OPT_DISABLE_DS390 || !OPT_DISABLE_MCS51
-    { 0,    "--parms-in-bank1",     &options.parms_in_bank1,"MCS51/DS390 - use Bank1 for parameter passing"},
-#endif
     { 0,    OPTION_NO_XINIT_OPT,    &options.noXinitOpt, "don't memcpy initialized xram from code"},
     { 0,    OPTION_NO_CCODE_IN_ASM, &options.noCcodeInAsm, "don't include c-code as comments in the asm file"},
     { 0,    OPTION_NO_PEEP_COMMENTS, &options.noPeepComments, "don't include peephole optimizer comments"},
     { 0,    OPTION_VERBOSE_ASM,     &options.verboseAsm, "include code generator comments"},
-#if !OPT_DISABLE_Z80 || !OPT_DISABLE_GBZ80
-    { 0,    "--no-std-crt0", &options.no_std_crt0, "For the z80/gbz80 do not link default crt0.o"},
-#endif
     { 0,    OPTION_SHORT_IS_8BITS,  NULL, "Make short 8 bits (for old times sake)" },
     { 0,    OPTION_CODE_SEG,        NULL, "<name> use this name for the code segment" },
     { 0,    OPTION_CONST_SEG,       NULL, "<name> use this name for the const segment" },
@@ -270,13 +244,6 @@ optionsTable[] = {
     { 0,    OPTION_STACK_LOC,       NULL, "<nnnn> Stack pointer initial value" },
     { 0,    OPTION_DATA_LOC,        NULL, "<nnnn> Direct data start location" },
     { 0,    OPTION_IDATA_LOC,       NULL, NULL },
-#if !OPT_DISABLE_DS390 || !OPT_DISABLE_MCS51 || !OPT_DISABLE_PIC
-    { 0,    OPTION_STACK_SIZE,      NULL,"MCS51/DS390/PIC - Tells the linker to allocate this space for stack"},
-#endif
-#if !OPT_DISABLE_DS390 || !OPT_DISABLE_MCS51
-    { 0,    OPTION_PACK_IRAM,       NULL,"MCS51/DS390 - Tells the linker to pack variables in internal ram (default)"},
-    { 0,    OPTION_NO_PACK_IRAM,    &options.no_pack_iram,"MCS51/DS390 - Tells the linker not to pack variables in internal ram"},
-#endif
 
     /* End of options */
     { 0,    NULL }
@@ -922,12 +889,6 @@ parseCmdLine (int argc, char **argv)
               exit (EXIT_SUCCESS);
             }
 
-          if (strcmp (argv[i], OPTION_STACK_8BIT) == 0)
-            {
-              options.stack10bit = 0;
-              continue;
-            }
-
           if (strcmp (argv[i], OPTION_OUT_FMT_IHX) == 0)
             {
               options.out_fmt = 0;
@@ -958,12 +919,6 @@ parseCmdLine (int argc, char **argv)
               continue;
             }
 
-          if (strcmp (argv[i], OPTION_FLAT24_MODEL) == 0)
-            {
-              _setModel (MODEL_FLAT24, argv[i]);
-              continue;
-            }
-
           if (strcmp (argv[i], OPTION_DUMP_ALL) == 0)
             {
               options.dump_rassgn =
@@ -1013,12 +968,6 @@ parseCmdLine (int argc, char **argv)
               continue;
             }
 
-          if (strcmp (argv[i], OPTION_STACK_SIZE) == 0)
-            {
-              options.stack_size = getIntArg(OPTION_STACK_SIZE, argv, &i, argc);
-              continue;
-            }
-
           if (strcmp (argv[i], OPTION_XRAM_LOC) == 0)
             {
               options.xdata_loc = getIntArg(OPTION_XRAM_LOC, argv, &i, argc);
@@ -1123,12 +1072,6 @@ parseCmdLine (int argc, char **argv)
               continue;
             }
 
-          if (strcmp (argv[i], OPTION_TINI_LIBID) == 0)
-            {
-              options.tini_libid = getIntArg(OPTION_TINI_LIBID, argv, &i, argc);
-              continue;
-            }
-
           if (strcmp (argv[i], OPTION_STD_C89) == 0)
             {
               options.std_c99 = 0;
index 7ed6889e9d2bdd70ae9be38758b188a5b8261d8e..ae17bdc26aeeca2fc7400b837ffd5147b7e31054 100644 (file)
@@ -18,6 +18,25 @@ static char _defaultRules[] =
 #include "peeph.rul"
 };
 
+#define OPTION_STACK_8BIT       "--stack-8bit"
+#define OPTION_FLAT24_MODEL     "--model-flat24"
+#define OPTION_STACK_SIZE       "--stack-size"
+
+static OPTION _ds390_options[] =
+  {
+    { 0, OPTION_FLAT24_MODEL,   NULL, "use the flat24 model for the ds390 (default)" },
+    { 0, OPTION_STACK_8BIT,     NULL, "use the 8bit stack for the ds390 (not supported yet)" },
+    { 0, OPTION_STACK_SIZE,     NULL, "Tells the linker to allocate this space for stack"},
+    { 0, "--pack-iram",         NULL, "Tells the linker to pack variables in internal ram (default)"},
+    { 0, "--no-pack-iram",      &options.no_pack_iram,"Tells the linker not to pack variables in internal ram"},
+    { 0, "--stack-10bit",       &options.stack10bit, "use the 10bit stack for ds390 (default)" },
+    { 0, "--use-accelerator",   &options.useAccelerator,"generate code for ds390 arithmetic accelerator"},
+    { 0, "--protect-sp-update", &options.protect_sp_update,"will disable interrupts during ESP:SP updates"},
+    { 0, "--parms-in-bank1",    &options.parms_in_bank1,"use Bank1 for parameter passing"},
+    { 0, NULL }
+  };
+
+
 /* list of key words used by msc51 */
 static char *_ds390_keywords[] =
 {
@@ -52,19 +71,19 @@ static char *_ds390_keywords[] =
 static builtins __ds390_builtins[] = {
     { "__builtin_memcpy_x2x","v",3,{"cx*","cx*","i"}}, /* void __builtin_memcpy_x2x (xdata char *,xdata char *,int) */
     { "__builtin_memcpy_c2x","v",3,{"cx*","cp*","i"}}, /* void __builtin_memcpy_c2x (xdata char *,code  char *,int) */
-    { "__builtin_memset_x","v",3,{"cx*","c","i"}},     /* void __builtin_memset     (xdata char *,char,int)        */
+    { "__builtin_memset_x","v",3,{"cx*","c","i"}},     /* void __builtin_memset     (xdata char *,char,int)         */
     /* __builtin_inp - used to read from a memory mapped port, increment first pointer */
     { "__builtin_inp","v",3,{"cx*","cx*","i"}},        /* void __builtin_inp        (xdata char *,xdata char *,int) */
     /* __builtin_inp - used to write to a memory mapped port, increment first pointer */
     { "__builtin_outp","v",3,{"cx*","cx*","i"}},       /* void __builtin_outp       (xdata char *,xdata char *,int) */
-    { "__builtin_swapw","us",1,{"us"}},                       /* unsigned short __builtin_swapw (unsigned short) */
+    { "__builtin_swapw","us",1,{"us"}},                /* unsigned short __builtin_swapw (unsigned short) */
     { "__builtin_memcmp_x2x","c",3,{"cx*","cx*","i"}}, /* void __builtin_memcmp_x2x (xdata char *,xdata char *,int) */
     { "__builtin_memcmp_c2x","c",3,{"cx*","cp*","i"}}, /* void __builtin_memcmp_c2x (xdata char *,code  char *,int) */
-    { NULL , NULL,0, {NULL}}                      /* mark end of table */
+    { NULL , NULL,0, {NULL}}                       /* mark end of table */
 };
 void ds390_assignRegisters (ebbIndex * ebbi);
 
-static int regParmFlg = 0;     /* determine if we can register a parameter */
+static int regParmFlg = 0;      /* determine if we can register a parameter */
 
 static void
 _ds390_init (void)
@@ -84,29 +103,29 @@ _ds390_regparm (sym_link * l, bool reentrant)
     if (IS_SPEC(l) && (SPEC_NOUN(l) == V_BIT))
         return 0;
     if (options.parms_in_bank1 == 0) {
-       /* simple can pass only the first parameter in a register */
-       if (regParmFlg)
-           return 0;
+        /* simple can pass only the first parameter in a register */
+        if (regParmFlg)
+            return 0;
 
-       regParmFlg = 1;
-       return 1;
+        regParmFlg = 1;
+        return 1;
     } else {
-       int size = getSize(l);
-       int remain ;
-
-       /* first one goes the usual way to DPTR */
-       if (regParmFlg == 0) {
-           regParmFlg += 4 ;
-           return 1;
-       }
-       /* second one onwards goes to RB1_0 thru RB1_7 */
+        int size = getSize(l);
+        int remain ;
+
+        /* first one goes the usual way to DPTR */
+        if (regParmFlg == 0) {
+            regParmFlg += 4 ;
+            return 1;
+        }
+        /* second one onwards goes to RB1_0 thru RB1_7 */
         remain = regParmFlg - 4;
-       if (size > (8 - remain)) {
-           regParmFlg = 12 ;
-           return 0;
-       }
-       regParmFlg += size ;
-       return regParmFlg - size + 1;
+        if (size > (8 - remain)) {
+            regParmFlg = 12 ;
+            return 0;
+        }
+        regParmFlg += size ;
+        return regParmFlg - size + 1;
     }
 }
 
@@ -116,6 +135,21 @@ _ds390_parseOptions (int *pargc, char **argv, int *i)
   /* TODO: allow port-specific command line options to specify
    * segment names here.
    */
+  if (!strcmp (argv[*i], OPTION_STACK_8BIT))
+    {
+      options.stack10bit = 0;
+      return TRUE;
+    }
+  else if (!strcmp (argv[*i], OPTION_FLAT24_MODEL))
+    {
+      options.model = MODEL_FLAT24;
+      return TRUE;
+    }
+  else if (!strcmp (argv[*i], OPTION_STACK_SIZE))
+    {
+      options.stack_size = getIntArg (OPTION_STACK_SIZE, argv, i, *pargc);
+      return TRUE;
+    }
   return FALSE;
 }
 
@@ -131,7 +165,7 @@ _ds390_finaliseOptions (void)
    */
   if (options.model != MODEL_FLAT24)  {
       fprintf (stderr,
-              "*** warning: ds390 port small and large model experimental.\n");
+               "*** warning: ds390 port small and large model experimental.\n");
       if (options.model == MODEL_LARGE)
       {
         port->mem.default_local_map = xdata;
@@ -147,13 +181,13 @@ _ds390_finaliseOptions (void)
     port->s.fptr_size = 3;
     port->s.gptr_size = 4;
 
-    port->stack.isr_overhead += 2;     /* Will save dpx on ISR entry. */
+    port->stack.isr_overhead += 2;      /* Will save dpx on ISR entry. */
 
-    port->stack.call_overhead += 2;    /* This acounts for the extra byte
-                                * of return addres on the stack.
-                                * but is ugly. There must be a
-                                * better way.
-                                */
+    port->stack.call_overhead += 2;     /* This acounts for the extra byte
+                                 * of return addres on the stack.
+                                 * but is ugly. There must be a
+                                 * better way.
+                                 */
 
     port->mem.default_local_map = xdata;
     port->mem.default_globl_map = xdata;
@@ -161,16 +195,16 @@ _ds390_finaliseOptions (void)
     if (!options.stack10bit)
     {
     fprintf (stderr,
-            "*** error: ds390 port only supports the 10 bit stack mode.\n");
+             "*** error: ds390 port only supports the 10 bit stack mode.\n");
     } else {
-       if (!options.stack_loc) options.stack_loc = 0x400008;
+        if (!options.stack_loc) options.stack_loc = 0x400008;
     }
 
     /* generate native code 16*16 mul/div */
     if (options.useAccelerator)
-           port->support.muldiv=2;
+            port->support.muldiv=2;
     else
-           port->support.muldiv=1;
+            port->support.muldiv=1;
 
      /* Fixup the memory map for the stack; it is now in
      * far space and requires a FPOINTER to access it.
@@ -179,7 +213,7 @@ _ds390_finaliseOptions (void)
     istack->ptrType = FPOINTER;
 
     if (options.parms_in_bank1) {
-       addSet(&preArgvSet, Safe_strdup("-DSDCC_PARMS_IN_BANK1"));
+        addSet(&preArgvSet, Safe_strdup("-DSDCC_PARMS_IN_BANK1"));
     }
   }  /* MODEL_FLAT24 */
 }
@@ -226,9 +260,9 @@ _ds390_genAssemblerPreamble (FILE * of)
       fputs ("mc\t=\t0xD5\n", of);
       fputs ("F1\t=\t0xD1\t; user flag\n", of);
       if (options.parms_in_bank1) {
-         int i ;
-         for (i=0; i < 8 ; i++ )
-             fprintf (of,"b1_%d\t=\t0x%02X\n",i,8+i);
+          int i ;
+          for (i=0; i < 8 ; i++ )
+              fprintf (of,"b1_%d\t=\t0x%02X\n",i,8+i);
       }
 }
 
@@ -267,13 +301,13 @@ _ds390_genIVT (struct dbuf_s * oBuf, symbol ** interrupts, int maxInterrupts)
   for (i = 0; i < maxInterrupts; i++)
     {
       if (interrupts[i])
-       {
-         dbuf_printf (oBuf, "\tljmp\t%s\n\t.ds\t4\n", interrupts[i]->rname);
-       }
+        {
+          dbuf_printf (oBuf, "\tljmp\t%s\n\t.ds\t4\n", interrupts[i]->rname);
+        }
       else
-       {
-         dbuf_printf (oBuf, "\treti\n\t.ds\t7\n");
-       }
+        {
+          dbuf_printf (oBuf, "\treti\n\t.ds\t7\n");
+        }
     }
 
   dbuf_printf (oBuf, "__reset_vect:\n\tljmp\t__sdcc_gsinit_startup\n");
@@ -327,9 +361,9 @@ static bool cseCostEstimation (iCode *ic, iCode *pdic)
        so we will cse only if they are local (i.e. both ic & pdic belong to
        the same basic block */
     if (IS_BITWISE_OP(ic) || ic->op == '+' || ic->op == '-') {
-       /* then if they are the same Basic block then ok */
-       if (ic->eBBlockNum == pdic->eBBlockNum) return 1;
-       else return 0;
+        /* then if they are the same Basic block then ok */
+        if (ic->eBBlockNum == pdic->eBBlockNum) return 1;
+        else return 0;
     }
 
     /* for others it is cheaper to do the cse */
@@ -395,15 +429,15 @@ instructionSize(char *inst, char *op1, char *op2)
       if (*(inst+3)=='c') return 1; /* movc */
       if (IS_C (op1) || IS_C (op2)) return 2;
       if (IS_A (op1))
-       {
-         if (IS_Rn (op2) || IS_atRi (op2)) return 1;
-         return 2;
-       }
+        {
+          if (IS_Rn (op2) || IS_atRi (op2)) return 1;
+          return 2;
+        }
       if (IS_Rn(op1) || IS_atRi(op1))
-       {
-         if (IS_A(op2)) return 1;
-         return 2;
-       }
+        {
+          if (IS_A(op2)) return 1;
+          return 2;
+        }
       if (strcmp (op1, "dptr") == 0) return 3+isflat24;
       if (IS_A (op2) || IS_Rn (op2) || IS_atRi (op2)) return 2;
       return 3;
@@ -426,7 +460,7 @@ instructionSize(char *inst, char *op1, char *op2)
   if (ISINST ("jb")) return 3;
   if (ISINST ("jnb")) return 3;
   if (ISINST ("jbc")) return 3;
-  if (ISINST ("jmp")) return 1;        // always jmp @a+dptr
+  if (ISINST ("jmp")) return 1; // always jmp @a+dptr
   if (ISINST ("jz")) return 2;
   if (ISINST ("jnz")) return 2;
   if (ISINST ("cjne")) return 3;
@@ -455,15 +489,15 @@ instructionSize(char *inst, char *op1, char *op2)
     {
       if (IS_C(op1)) return 2;
       if (IS_A(op1))
-       {
-         if (IS_Rn(op2) || IS_atRi(op2)) return 1;
-         return 2;
-       }
+        {
+          if (IS_Rn(op2) || IS_atRi(op2)) return 1;
+          return 2;
+        }
       else
-       {
-         if (IS_A(op2)) return 2;
-         return 3;
-       }
+        {
+          if (IS_A(op2)) return 2;
+          return 3;
+        }
     }
   if (ISINST ("clr") || ISINST ("setb") || ISINST ("cpl"))
     {
@@ -570,8 +604,8 @@ updateOpRW (asmLineNode *aln, char *op, char *optype, int currentDPS)
     *dot = '\0';
 
   opdat = bsearch (op, ds390operandDataTable,
-                  sizeof(ds390operandDataTable)/sizeof(ds390operanddata),
-                  sizeof(ds390operanddata), ds390operandCompare);
+                   sizeof(ds390operandDataTable)/sizeof(ds390operanddata),
+                   sizeof(ds390operanddata), ds390operandCompare);
 
   if (opdat)
     {
@@ -581,17 +615,17 @@ updateOpRW (asmLineNode *aln, char *op, char *optype, int currentDPS)
   if (!strcmp(op, "dptr"))
     {
       if (!currentDPS)
-       {
-         regIdx1 = DPL_IDX;
-         regIdx2 = DPH_IDX;
-         regIdx3 = DPX_IDX;
-       }
+        {
+          regIdx1 = DPL_IDX;
+          regIdx2 = DPH_IDX;
+          regIdx3 = DPX_IDX;
+        }
       else
-       {
-         regIdx1 = DPL1_IDX;
-         regIdx2 = DPH1_IDX;
-         regIdx3 = DPX1_IDX;
-       }
+        {
+          regIdx1 = DPL1_IDX;
+          regIdx2 = DPH1_IDX;
+          regIdx3 = DPX1_IDX;
+        }
     }
 
   if (strchr(optype,'r'))
@@ -619,22 +653,22 @@ updateOpRW (asmLineNode *aln, char *op, char *optype, int currentDPS)
       if (!strcmp(op, "@r1"))
         aln->regsRead = bitVectSetBit (aln->regsRead, R1_IDX);
       if (strstr(op, "dptr"))
-       {
-         if (!currentDPS)
-           {
-             aln->regsRead = bitVectSetBit (aln->regsRead, DPL_IDX);
-             aln->regsRead = bitVectSetBit (aln->regsRead, DPH_IDX);
-             aln->regsRead = bitVectSetBit (aln->regsRead, DPX_IDX);
-           }
-         else
-           {
-             aln->regsRead = bitVectSetBit (aln->regsRead, DPL1_IDX);
-             aln->regsRead = bitVectSetBit (aln->regsRead, DPH1_IDX);
-             aln->regsRead = bitVectSetBit (aln->regsRead, DPX1_IDX);
-           }
-       }
+        {
+          if (!currentDPS)
+            {
+              aln->regsRead = bitVectSetBit (aln->regsRead, DPL_IDX);
+              aln->regsRead = bitVectSetBit (aln->regsRead, DPH_IDX);
+              aln->regsRead = bitVectSetBit (aln->regsRead, DPX_IDX);
+            }
+          else
+            {
+              aln->regsRead = bitVectSetBit (aln->regsRead, DPL1_IDX);
+              aln->regsRead = bitVectSetBit (aln->regsRead, DPH1_IDX);
+              aln->regsRead = bitVectSetBit (aln->regsRead, DPX1_IDX);
+            }
+        }
       if (strstr(op, "a+"))
-       aln->regsRead = bitVectSetBit (aln->regsRead, A_IDX);
+        aln->regsRead = bitVectSetBit (aln->regsRead, A_IDX);
     }
 }
 
@@ -723,7 +757,7 @@ asmLineNodeFromLineNode (lineNode *ln, int currentDPS)
         break;
       else
         if (opsize < sizeof(inst))
-         *op++ = tolower(*p), opsize++;
+          *op++ = tolower(*p), opsize++;
     }
   *op = '\0';
 
@@ -755,8 +789,8 @@ asmLineNodeFromLineNode (lineNode *ln, int currentDPS)
   aln->regsWritten = newBitVect (END_IDX);
 
   opdat = bsearch (inst, ds390opcodeDataTable,
-                  sizeof(ds390opcodeDataTable)/sizeof(ds390opcodedata),
-                  sizeof(ds390opcodedata), ds390opcodeCompare);
+                   sizeof(ds390opcodeDataTable)/sizeof(ds390opcodedata),
+                   sizeof(ds390opcodedata), ds390opcodeCompare);
 
   if (opdat)
     {
@@ -828,22 +862,22 @@ PORT ds390_port =
 {
   TARGET_ID_DS390,
   "ds390",
-  "DS80C390",                  /* Target name */
+  "DS80C390",                   /* Target name */
   NULL,
   {
     glue,
-    TRUE,                      /* Emit glue around main */
+    TRUE,                       /* Emit glue around main */
     MODEL_SMALL | MODEL_LARGE | MODEL_FLAT24,
     MODEL_SMALL
   },
   {
     _asmCmd,
     NULL,
-    "-plosgffc",               /* Options with debug */
-    "-plosgff",                        /* Options without debug */
+    "-plosgffc",                /* Options with debug */
+    "-plosgff",                 /* Options without debug */
     0,
     ".asm",
-    NULL                       /* no do_assemble function */
+    NULL                        /* no do_assemble function */
   },
   {
     _linkCmd,
@@ -859,12 +893,12 @@ PORT ds390_port =
     getRegsWritten
   },
   {
-       /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
+        /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
     1, 2, 2, 4, 1, 2, 3, 1, 4, 4
   },
   
   /* tags for generic pointers */
-  { 0x00, 0x40, 0x60, 0x80 },          /* far, near, xstack, code */
+  { 0x00, 0x40, 0x60, 0x80 },           /* far, near, xstack, code */
 
   {
     "XSEG    (XDATA)",
@@ -880,12 +914,12 @@ PORT ds390_port =
     "OSEG    (OVR,DATA)",
     "GSFINAL (CODE)",
     "HOME    (CODE)",
-    "XISEG   (XDATA)",         // initialized xdata
-    "XINIT   (CODE)",          // a code copy of xiseg
-    "CONST   (CODE)",          // const_name - const data (code or not)
-    "CABS    (ABS,CODE)",      // cabs_name - const absolute data (code or not)
-    "XABS    (ABS,XDATA)",     // xabs_name - absolute xdata/pdata
-    "IABS    (ABS,DATA)",      // iabs_name - absolute idata/data
+    "XISEG   (XDATA)",          // initialized xdata
+    "XINIT   (CODE)",           // a code copy of xiseg
+    "CONST   (CODE)",           // const_name - const data (code or not)
+    "CABS    (ABS,CODE)",       // cabs_name - const absolute data (code or not)
+    "XABS    (ABS,XDATA)",      // xabs_name - absolute xdata/pdata
+    "IABS    (ABS,DATA)",       // iabs_name - absolute idata/data
     NULL,
     NULL,
     1
@@ -912,7 +946,7 @@ PORT ds390_port =
   "_",
   _ds390_init,
   _ds390_parseOptions,
-  NULL,
+  _ds390_options,
   NULL,
   _ds390_finaliseOptions,
   _ds390_setDefaultOptions,
@@ -920,38 +954,69 @@ PORT ds390_port =
   _ds390_getRegName,
   _ds390_keywords,
   _ds390_genAssemblerPreamble,
-  NULL,                                /* no genAssemblerEnd */
+  NULL,                         /* no genAssemblerEnd */
   _ds390_genIVT,
   _ds390_genXINIT,
-  NULL,                        /* genInitStartup */
+  NULL,                         /* genInitStartup */
   _ds390_reset_regparm,
   _ds390_regparm,
   NULL,
   NULL,
   _ds390_nativeMulCheck,
-  hasExtBitOp,                 /* hasExtBitOp */
-  oclsExpense,                 /* oclsExpense */
+  hasExtBitOp,                  /* hasExtBitOp */
+  oclsExpense,                  /* oclsExpense */
   FALSE,
-  TRUE,                                /* little endian */
-  0,                           /* leave lt */
-  0,                           /* leave gt */
-  1,                           /* transform <= to ! > */
-  1,                           /* transform >= to ! < */
-  1,                           /* transform != to !(a == b) */
-  0,                           /* leave == */
+  TRUE,                         /* little endian */
+  0,                            /* leave lt */
+  0,                            /* leave gt */
+  1,                            /* transform <= to ! > */
+  1,                            /* transform >= to ! < */
+  1,                            /* transform != to !(a == b) */
+  0,                            /* leave == */
   FALSE,                        /* No array initializer support. */
   cseCostEstimation,
   __ds390_builtins,             /* table of builtin functions */
-  GPOINTER,                    /* treat unqualified pointers as "generic" pointers */
-  1,                           /* reset labelKey to 1 */
-  1,                           /* globals & local static allowed */
+  GPOINTER,                     /* treat unqualified pointers as "generic" pointers */
+  1,                            /* reset labelKey to 1 */
+  1,                            /* globals & local static allowed */
   PORT_MAGIC
 };
 
 /*---------------------------------------------------------------------------------*/
-/*                              TININative specific                               */
+/*                               TININative specific                               */
 /*---------------------------------------------------------------------------------*/
-/* Globals */
+
+#define OPTION_TINI_LIBID "--tini-libid"
+
+static OPTION _tininative_options[] =
+  {
+    { 0, OPTION_FLAT24_MODEL,   NULL, "use the flat24 model for the ds390 (default)" },
+    { 0, OPTION_STACK_8BIT,     NULL, "use the 8bit stack for the ds390 (not supported yet)" },
+    { 0, OPTION_STACK_SIZE,     NULL, "Tells the linker to allocate this space for stack"},
+    { 0, "--pack-iram",         NULL, "Tells the linker to pack variables in internal ram (default)"},
+    { 0, "--no-pack-iram",      &options.no_pack_iram,"Tells the linker not to pack variables in internal ram"},
+    { 0, "--stack-10bit",       &options.stack10bit, "use the 10bit stack for ds390 (default)" },
+    { 0, "--use-accelerator",   &options.useAccelerator,"generate code for ds390 arithmetic accelerator"},
+    { 0, "--protect-sp-update", &options.protect_sp_update,"will disable interrupts during ESP:SP updates"},
+    { 0, "--parms-in-bank1",    &options.parms_in_bank1,"use Bank1 for parameter passing"},
+    { 0, OPTION_TINI_LIBID,     NULL, "<nnnn> LibraryID used in -mTININative"},
+    { 0, NULL }
+  };
+
+static bool
+_tininative_parseOptions (int *pargc, char **argv, int *i)
+{
+  if (_ds390_parseOptions (pargc, argv, i))
+    return TRUE;
+
+  if (!strcmp (argv[*i], OPTION_TINI_LIBID))
+    {
+      options.tini_libid = getIntArg (OPTION_TINI_LIBID, argv, i, *pargc);
+      return TRUE;
+    }
+  return FALSE;
+}
+
 static void _tininative_init (void)
 {
     asm_addTree (&asm_a390_mapping);
@@ -970,35 +1035,35 @@ static void _tininative_finaliseOptions (void)
      * adjust pointer sizes.
      */
     if (options.model != MODEL_FLAT24)  {
-       options.model = MODEL_FLAT24 ;
-       fprintf(stderr,"TININative supports only MODEL FLAT24\n");
+        options.model = MODEL_FLAT24 ;
+        fprintf(stderr,"TININative supports only MODEL FLAT24\n");
     }
     port->s.fptr_size = 3;
     port->s.gptr_size = 4;
 
-    port->stack.isr_overhead += 2;     /* Will save dpx on ISR entry. */
+    port->stack.isr_overhead += 2;      /* Will save dpx on ISR entry. */
 
-    port->stack.call_overhead += 2;    /* This acounts for the extra byte
-                                        * of return addres on the stack.
-                                        * but is ugly. There must be a
-                                        * better way.
-                                        */
+    port->stack.call_overhead += 2;     /* This acounts for the extra byte
+                                         * of return addres on the stack.
+                                         * but is ugly. There must be a
+                                         * better way.
+                                         */
 
     port->mem.default_local_map = xdata;
     port->mem.default_globl_map = xdata;
 
     if (!options.stack10bit) {
-       options.stack10bit = 1;
-       fprintf(stderr,"TININative supports only stack10bit \n");
+        options.stack10bit = 1;
+        fprintf(stderr,"TININative supports only stack10bit \n");
     }
 
     if (!options.stack_loc) options.stack_loc = 0x400008;
 
     /* generate native code 16*16 mul/div */
     if (options.useAccelerator)
-       port->support.muldiv=2;
+        port->support.muldiv=2;
     else
-       port->support.muldiv=1;
+        port->support.muldiv=1;
 
     /* Fixup the memory map for the stack; it is now in
      * far space and requires a FPOINTER to access it.
@@ -1012,6 +1077,7 @@ static int _tininative_genIVT (struct dbuf_s * oBuf, symbol ** interrupts, int m
 {
     return TRUE;
 }
+
 static void _tininative_genAssemblerPreamble (FILE * of)
 {
     fputs("$include(tini.inc)\n", of);
@@ -1027,13 +1093,13 @@ static void _tininative_genAssemblerPreamble (FILE * of)
     fputs("LibraryID:\n",of);
     fputs("\tdb \"DS\"\n",of);
     if (options.tini_libid) {
-       fprintf(of,"\tdb 0,0,0%02xh,0%02xh,0%02xh,0%02xh\n",
-               (options.tini_libid>>24 & 0xff),
-               (options.tini_libid>>16 & 0xff),
-               (options.tini_libid>>8 & 0xff),
-               (options.tini_libid  & 0xff));
+        fprintf(of,"\tdb 0,0,0%02xh,0%02xh,0%02xh,0%02xh\n",
+                (options.tini_libid>>24 & 0xff),
+                (options.tini_libid>>16 & 0xff),
+                (options.tini_libid>>8 & 0xff),
+                (options.tini_libid  & 0xff));
     } else {
-       fprintf(of,"\tdb 0,0,0,0,0,1\n");
+        fprintf(of,"\tdb 0,0,0,0,0,1\n");
     }
 
 }
@@ -1045,20 +1111,20 @@ static void _tininative_genAssemblerEnd (FILE * of)
 static void _tininative_do_assemble (set *asmOptions)
 {
     static const char *macroCmd[] = {
-       "macro","$1.a51",NULL
+        "macro","$1.a51",NULL
     };
     static const char *a390Cmd[] = {
-       "a390","$1.mpp",NULL
+        "a390","$1.mpp",NULL
     };
     char buffer[100];
 
     buildCmdLine(buffer,macroCmd,dstFileName,NULL,NULL,NULL);
     if (my_system(buffer)) {
-       exit(1);
+        exit(1);
     }
     buildCmdLine(buffer,a390Cmd,dstFileName,NULL,NULL,asmOptions);
     if (my_system(buffer)) {
-       exit(1);
+        exit(1);
     }
 }
 
@@ -1095,7 +1161,7 @@ static char *_tininative_keywords[] =
 static builtins __tininative_builtins[] = {
     { "__builtin_memcpy_x2x","v",3,{"cx*","cx*","i"}}, /* void __builtin_memcpy_x2x (xdata char *,xdata char *,int) */
     { "__builtin_memcpy_c2x","v",3,{"cx*","cp*","i"}}, /* void __builtin_memcpy_c2x (xdata char *,code  char *,int) */
-    { "__builtin_memset_x","v",3,{"cx*","c","i"}},     /* void __builtin_memset     (xdata char *,char,int)        */
+    { "__builtin_memset_x","v",3,{"cx*","c","i"}},     /* void __builtin_memset     (xdata char *,char,int)         */
     /* TINI NatLib */
     { "NatLib_LoadByte","c",1,{"c"}},                  /* char  Natlib_LoadByte  (0 based parameter number)         */
     { "NatLib_LoadShort","s",1,{"c"}},                 /* short Natlib_LoadShort (0 based parameter number)         */
@@ -1112,13 +1178,13 @@ static builtins __tininative_builtins[] = {
     { "MM_XMalloc","i",1,{"l"}},                       /* int  MM_XMalloc (long)                */
     { "MM_Malloc","i",1,{"i"}},                        /* int  MM_Malloc  (int)                 */
     { "MM_ApplicationMalloc","i",1,{"i"}},             /* int  MM_ApplicationMalloc  (int)      */
-    { "MM_Free","i",1,{"i"}},                          /* int  MM_Free  (int)                  */
-    { "MM_Deref","cx*",1,{"i"}},                       /* char *MM_Free  (int)                 */
+    { "MM_Free","i",1,{"i"}},                          /* int  MM_Free  (int)                   */
+    { "MM_Deref","cx*",1,{"i"}},                       /* char *MM_Free  (int)                  */
     { "MM_UnrestrictedPersist","c",1,{"i"}},           /* char  MM_UnrestrictedPersist  (int)   */
     /* System functions */
     { "System_ExecJavaProcess","c",2,{"cx*","i"}},     /* char System_ExecJavaProcess (char *,int) */
-    { "System_GetRTCRegisters","v",1,{"cx*"}},        /* void System_GetRTCRegisters (char *) */
-    { "System_SetRTCRegisters","v",1,{"cx*"}},        /* void System_SetRTCRegisters (char *) */
+    { "System_GetRTCRegisters","v",1,{"cx*"}},         /* void System_GetRTCRegisters (char *) */
+    { "System_SetRTCRegisters","v",1,{"cx*"}},         /* void System_SetRTCRegisters (char *) */
     { "System_ThreadSleep","v",2,{"l","c"}},           /* void System_ThreadSleep (long,char)  */
     { "System_ThreadSleep_ExitCriticalSection","v",2,{"l","c"}},/* void System_ThreadSleep_ExitCriticalSection (long,char)  */
     { "System_ProcessSleep","v",2,{"l","c"}},           /* void System_ProcessSleep (long,char)  */
@@ -1133,30 +1199,31 @@ static builtins __tininative_builtins[] = {
     { "System_RemovePoll","c",1,{"vF*"}},              /* char System_RemovePoll ((void *func pointer)()) */
     { "System_GetCurrentProcessId","c",0,{NULL}},      /* char System_GetCurrentProcessId() */
     { "System_GetCurrentThreadId","c",0,{NULL}},       /* char System_GetCurrentThreadId() */
-    { NULL , NULL,0, {NULL}}                      /* mark end of table */
+    { NULL , NULL,0, {NULL}}                       /* mark end of table */
 };
 
 static const char *_a390Cmd[] =
 {
   "macro", "$l", "$3", "$1.a51", NULL
 };
+
 PORT tininative_port =
 {
   TARGET_ID_DS390,
   "TININative",
-  "DS80C390",                  /* Target name */
-       NULL,                   /* processor */
+  "DS80C390",                   /* Target name */
+        NULL,                   /* processor */
   {
     glue,
-    FALSE,                     /* Emit glue around main */
+    FALSE,                      /* Emit glue around main */
     MODEL_FLAT24,
     MODEL_FLAT24
   },
   {
     _a390Cmd,
     NULL,
-    "-l",              /* Options with debug */
-    "-l",              /* Options without debug */
+    "-l",               /* Options with debug */
+    "-l",               /* Options without debug */
     0,
     ".a51",
     _tininative_do_assemble
@@ -1175,11 +1242,11 @@ PORT tininative_port =
     getRegsWritten
   },
   {
-       /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
+        /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
     1, 2, 2, 4, 1, 3, 3, 1, 4, 4
   },
   /* tags for generic pointers */
-  { 0x00, 0x40, 0x60, 0x80 },          /* far, near, xstack, code */
+  { 0x00, 0x40, 0x60, 0x80 },           /* far, near, xstack, code */
 
   {
     "XSEG    (XDATA)",
@@ -1197,10 +1264,10 @@ PORT tininative_port =
     "HOME    (CODE)",
     NULL,
     NULL,
-    "CONST   (CODE)",          // const_name - const data (code or not)
-    "CABS    (ABS,CODE)",      // cabs_name - const absolute data (code or not)
-    "XABS    (ABS,XDATA)",     // xabs_name - absolute xdata/pdata
-    "IABS    (ABS,DATA)",      // iabs_name - absolute idata/data
+    "CONST   (CODE)",           // const_name - const data (code or not)
+    "CABS    (ABS,CODE)",       // cabs_name - const absolute data (code or not)
+    "XABS    (ABS,XDATA)",      // xabs_name - absolute xdata/pdata
+    "IABS    (ABS,DATA)",       // iabs_name - absolute idata/data
     NULL,
     NULL,
     1
@@ -1226,8 +1293,8 @@ PORT tininative_port =
   },
   "",
   _tininative_init,
-  _ds390_parseOptions,
-  NULL,
+  _tininative_parseOptions,
+  _tininative_options,
   NULL,
   _tininative_finaliseOptions,
   _tininative_setDefaultOptions,
@@ -1238,28 +1305,28 @@ PORT tininative_port =
   _tininative_genAssemblerEnd,
   _tininative_genIVT,
   NULL,
-  NULL,                        /* genInitStartup */
+  NULL,                         /* genInitStartup */
   _ds390_reset_regparm,
   _ds390_regparm,
   NULL,
   NULL,
   NULL,
-  hasExtBitOp,                 /* hasExtBitOp */
-  oclsExpense,                 /* oclsExpense */
+  hasExtBitOp,                  /* hasExtBitOp */
+  oclsExpense,                  /* oclsExpense */
   FALSE,
-  TRUE,                                /* little endian */
-  0,                           /* leave lt */
-  0,                           /* leave gt */
-  1,                           /* transform <= to ! > */
-  1,                           /* transform >= to ! < */
-  1,                           /* transform != to !(a == b) */
-  0,                           /* leave == */
+  TRUE,                         /* little endian */
+  0,                            /* leave lt */
+  0,                            /* leave gt */
+  1,                            /* transform <= to ! > */
+  1,                            /* transform >= to ! < */
+  1,                            /* transform != to !(a == b) */
+  0,                            /* leave == */
   FALSE,                        /* No array initializer support. */
   cseCostEstimation,
   __tininative_builtins,        /* table of builtin functions */
-  FPOINTER,                    /* treat unqualified pointers as far pointers */
-  0,                           /* DONOT reset labelKey */
-  0,                           /* globals & local static NOT allowed */
+  FPOINTER,                     /* treat unqualified pointers as far pointers */
+  0,                            /* DONOT reset labelKey */
+  0,                            /* globals & local static NOT allowed */
   PORT_MAGIC
 };
 
@@ -1281,6 +1348,23 @@ _ds400_genIVT (struct dbuf_s * oBuf, symbol ** interrupts, int maxInterrupts)
 }
 
 
+/*---------------------------------------------------------------------------------*/
+/*                               _ds400 specific                                   */
+/*---------------------------------------------------------------------------------*/
+
+static OPTION _ds400_options[] =
+  {
+    { 0, OPTION_FLAT24_MODEL,   NULL, "use the flat24 model for the ds400 (default)" },
+    { 0, OPTION_STACK_8BIT,     NULL, "use the 8bit stack for the ds400 (not supported yet)" },
+    { 0, OPTION_STACK_SIZE,     NULL, "Tells the linker to allocate this space for stack"},
+    { 0, "--pack-iram",         NULL, "Tells the linker to pack variables in internal ram (default)"},
+    { 0, "--no-pack-iram",      &options.no_pack_iram,"Tells the linker not to pack variables in internal ram"},
+    { 0, "--stack-10bit",       &options.stack10bit, "use the 10bit stack for ds400 (default)" },
+    { 0, "--use-accelerator",   &options.useAccelerator,"generate code for ds400 arithmetic accelerator"},
+    { 0, "--protect-sp-update", &options.protect_sp_update,"will disable interrupts during ESP:SP updates"},
+    { 0, "--parms-in-bank1",    &options.parms_in_bank1,"use Bank1 for parameter passing"},
+    { 0, NULL }
+  };
 
 static void
 _ds400_finaliseOptions (void)
@@ -1298,7 +1382,7 @@ _ds400_finaliseOptions (void)
    */
   if (options.model != MODEL_FLAT24)  {
       fprintf (stderr,
-              "*** warning: ds400 port small and large model experimental.\n");
+               "*** warning: ds400 port small and large model experimental.\n");
       if (options.model == MODEL_LARGE)
       {
         port->mem.default_local_map = xdata;
@@ -1314,13 +1398,13 @@ _ds400_finaliseOptions (void)
     port->s.fptr_size = 3;
     port->s.gptr_size = 4;
 
-    port->stack.isr_overhead += 2;     /* Will save dpx on ISR entry. */
+    port->stack.isr_overhead += 2;      /* Will save dpx on ISR entry. */
 
-    port->stack.call_overhead += 2;    /* This acounts for the extra byte
-                                * of return addres on the stack.
-                                * but is ugly. There must be a
-                                * better way.
-                                */
+    port->stack.call_overhead += 2;     /* This acounts for the extra byte
+                                 * of return addres on the stack.
+                                 * but is ugly. There must be a
+                                 * better way.
+                                 */
 
     port->mem.default_local_map = xdata;
     port->mem.default_globl_map = xdata;
@@ -1328,17 +1412,17 @@ _ds400_finaliseOptions (void)
     if (!options.stack10bit)
     {
     fprintf (stderr,
-            "*** error: ds400 port only supports the 10 bit stack mode.\n");
+             "*** error: ds400 port only supports the 10 bit stack mode.\n");
     } else {
-       if (!options.stack_loc) options.stack_loc = 0xffdc00;
-       // assumes IDM1:0 = 1:0, CMA = 1.
+        if (!options.stack_loc) options.stack_loc = 0xffdc00;
+        // assumes IDM1:0 = 1:0, CMA = 1.
     }
 
     /* generate native code 16*16 mul/div */
     if (options.useAccelerator)
-           port->support.muldiv=2;
+            port->support.muldiv=2;
     else
-           port->support.muldiv=1;
+            port->support.muldiv=1;
 
      /* Fixup the memory map for the stack; it is now in
      * far space and requires a FPOINTER to access it.
@@ -1347,7 +1431,7 @@ _ds400_finaliseOptions (void)
     istack->ptrType = FPOINTER;
 
     if (options.parms_in_bank1) {
-       addSet(&preArgvSet, Safe_strdup("-DSDCC_PARMS_IN_BANK1"));
+        addSet(&preArgvSet, Safe_strdup("-DSDCC_PARMS_IN_BANK1"));
     }
 
     // the DS400 rom calling interface uses register bank 3.
@@ -1361,11 +1445,11 @@ static void _ds400_generateRomDataArea(FILE *fp, bool isMain)
     /* Only do this for the file containing main() */
     if (isMain)
     {
-       fprintf(fp, "%s", iComments2);
-       fprintf(fp, "; the direct data area used by the DS80c400 ROM code.\n");
-       fprintf(fp, "%s", iComments2);
-       fprintf(fp, ".area ROMSEG (ABS,CON,DATA)\n\n");
-       fprintf(fp, ".ds 24 ; 24 bytes of directs used starting at 0x68\n\n");
+        fprintf(fp, "%s", iComments2);
+        fprintf(fp, "; the direct data area used by the DS80c400 ROM code.\n");
+        fprintf(fp, "%s", iComments2);
+        fprintf(fp, ".area ROMSEG (ABS,CON,DATA)\n\n");
+        fprintf(fp, ".ds 24 ; 24 bytes of directs used starting at 0x68\n\n");
     }
 }
 
@@ -1379,22 +1463,22 @@ PORT ds400_port =
 {
   TARGET_ID_DS400,
   "ds400",
-  "DS80C400",                  /* Target name */
+  "DS80C400",                   /* Target name */
   NULL,
   {
     glue,
-    TRUE,                      /* Emit glue around main */
+    TRUE,                       /* Emit glue around main */
     MODEL_SMALL | MODEL_LARGE | MODEL_FLAT24,
     MODEL_SMALL
   },
   {
     _asmCmd,
     NULL,
-    "-plosgffc",               /* Options with debug */
-    "-plosgff",                        /* Options without debug */
+    "-plosgffc",                /* Options with debug */
+    "-plosgff",                 /* Options without debug */
     0,
     ".asm",
-    NULL                       /* no do_assemble function */
+    NULL                        /* no do_assemble function */
   },
   {
     _linkCmd,
@@ -1410,12 +1494,12 @@ PORT ds400_port =
     getRegsWritten
   },
   {
-       /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
+        /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
     1, 2, 2, 4, 1, 2, 3, 1, 4, 4
   },
 
   /* tags for generic pointers */
-  { 0x00, 0x40, 0x60, 0x80 },          /* far, near, xstack, code */
+  { 0x00, 0x40, 0x60, 0x80 },           /* far, near, xstack, code */
 
   {
     "XSEG    (XDATA)",
@@ -1433,10 +1517,10 @@ PORT ds400_port =
     "HOME    (CODE)",
     "XISEG   (XDATA)", // initialized xdata
     "XINIT   (CODE)", // a code copy of xiseg
-    "CONST   (CODE)",          // const_name - const data (code or not)
-    "CABS    (ABS,CODE)",      // cabs_name - const absolute data (code or not)
-    "XABS    (ABS,XDATA)",     // xabs_name - absolute xdata/pdata
-    "IABS    (ABS,DATA)",      // iabs_name - absolute idata/data
+    "CONST   (CODE)",           // const_name - const data (code or not)
+    "CABS    (ABS,CODE)",       // cabs_name - const absolute data (code or not)
+    "XABS    (ABS,XDATA)",      // xabs_name - absolute xdata/pdata
+    "IABS    (ABS,DATA)",       // iabs_name - absolute idata/data
     NULL,
     NULL,
     1
@@ -1463,7 +1547,7 @@ PORT ds400_port =
   "_",
   _ds390_init,
   _ds390_parseOptions,
-  NULL,
+  _ds400_options,
   NULL,
   _ds400_finaliseOptions,
   _ds390_setDefaultOptions,
@@ -1471,30 +1555,30 @@ PORT ds400_port =
   _ds390_getRegName,
   _ds390_keywords,
   _ds390_genAssemblerPreamble,
-  NULL,                                /* no genAssemblerEnd */
+  NULL,                         /* no genAssemblerEnd */
   _ds400_genIVT,
   _ds390_genXINIT,
-  NULL,                        /* genInitStartup */
+  NULL,                         /* genInitStartup */
   _ds390_reset_regparm,
   _ds390_regparm,
   NULL,
   NULL,
   _ds390_nativeMulCheck,
-  hasExtBitOp,                 /* hasExtBitOp */
-  oclsExpense,                 /* oclsExpense */
+  hasExtBitOp,                  /* hasExtBitOp */
+  oclsExpense,                  /* oclsExpense */
   FALSE,
-  TRUE,                                /* little endian */
-  0,                           /* leave lt */
-  0,                           /* leave gt */
-  1,                           /* transform <= to ! > */
-  1,                           /* transform >= to ! < */
-  1,                           /* transform != to !(a == b) */
-  0,                           /* leave == */
+  TRUE,                         /* little endian */
+  0,                            /* leave lt */
+  0,                            /* leave gt */
+  1,                            /* transform <= to ! > */
+  1,                            /* transform >= to ! < */
+  1,                            /* transform != to !(a == b) */
+  0,                            /* leave == */
   FALSE,                        /* No array initializer support. */
   cseCostEstimation,
   __ds390_builtins,             /* table of builtin functions */
-  GPOINTER,                    /* treat unqualified pointers as "generic" pointers */
-  1,                           /* reset labelKey to 1 */
-  1,                           /* globals & local static allowed */
+  GPOINTER,                     /* treat unqualified pointers as "generic" pointers */
+  1,                            /* reset labelKey to 1 */
+  1,                            /* globals & local static allowed */
   PORT_MAGIC
 };
index 8027833e64bbdc682c2fe4044e3e5a76723ce4ff..b1676b91ea18d723d6c8503fe254b967bba688d5 100644 (file)
@@ -16,6 +16,17 @@ static char _defaultRules[] =
 #include "peeph.rul"
 };
 
+#define OPTION_STACK_SIZE       "--stack-size"
+
+static OPTION _mcs51_options[] =
+  {
+    { 0, OPTION_STACK_SIZE,  NULL, "Tells the linker to allocate this space for stack"},
+    { 0, "--parms-in-bank1", &options.parms_in_bank1, "use Bank1 for parameter passing"},
+    { 0, "--pack-iram",      NULL, "Tells the linker to pack variables in internal ram (default)"},
+    { 0, "--no-pack-iram",   &options.no_pack_iram, "Tells the linker not to pack variables in internal ram"},
+    { 0, NULL }
+  };
+
 /* list of key words used by msc51 */
 static char *_mcs51_keywords[] =
 {
@@ -113,6 +124,11 @@ _mcs51_parseOptions (int *pargc, char **argv, int *i)
   /* TODO: allow port-specific command line options to specify
    * segment names here.
    */
+  if (!strcmp (argv[*i], OPTION_STACK_SIZE))
+    {
+      options.stack_size = getIntArg(OPTION_STACK_SIZE, argv, i, *pargc);
+      return TRUE;
+    }
   return FALSE;
 }
 
@@ -790,7 +806,7 @@ PORT mcs51_port =
   "_",
   _mcs51_init,
   _mcs51_parseOptions,
-  NULL,
+  _mcs51_options,
   NULL,
   _mcs51_finaliseOptions,
   _mcs51_setDefaultOptions,
index 9b8cd24ccf3f31c1ddf86cdac28921bcc0cff825..d438a15f157ad85dbce84eb4e44e6a0863a93dd9 100644 (file)
 #include <errno.h>
 //#include "gen.h"
 
+#define OPTION_STACK_SIZE         "--stack-size"
+#define OPTION_UDATA_SECTION_NAME "--udata-section-name"
+
 
 static char _defaultRules[] =
 {
 #include "peeph.rul"
-       ""
-};
-
-/* list of key words used by pic14 */
-static char *_pic14_keywords[] =
-{
-       "at",
-       //"bit",
-       "code",
-       "critical",
-       "data",
-       "far",
-       "idata",
-       "interrupt",
-       "near",
-       "pdata",
-       "reentrant",
-       "sfr",
-       //"sbit",
-       "using",
-       "xdata",
-       "_data",
-       "_code",
-       "_generic",
-       "_near",
-       "_xdata",
-       "_pdata",
-       "_idata",
-       NULL
 };
 
 pic14_options_t pic14_options;
+extern int debug_verbose; /* from pcode.c */
 
-#define ARG_STACKLOC   "--stack-loc"
-#define ARG_STACKSIZ   "--stack-size"
+static OPTION _pic14_poptions[] =
+  {
+    { 0, "--debug-xtra",   &debug_verbose, "show more debug info in assembly output" },
+    { 0, "--no-pcode-opt", &pic14_options.disable_df, "disable (slightly faulty) optimization on pCode" },
+    { 0, OPTION_STACK_SIZE, NULL, "sets the size if the argument passing stack (default: 16, minimum: 4)" },
+    { 0, OPTION_UDATA_SECTION_NAME, NULL, "set udata section name" },
+    { 0, NULL, NULL, NULL }
+  };
 
-extern int debug_verbose;      /* from pcode.c */
-static OPTION _pic14_poptions[] = {
-       { 0 , "--debug-xtra", &debug_verbose, "show more debug info in assembly output" },
-       { 0 , "--no-pcode-opt", &pic14_options.disable_df, "disable (slightly faulty) optimization on pCode" },
-       { 0 , ARG_STACKLOC, NULL, "sets the lowest address of the argument passing stack" },
-       { 0 , ARG_STACKSIZ, NULL, "sets the size if the argument passing stack (default: 16, minimum: 4)" },
-       { 0 , NULL, NULL, NULL }
+/* list of key words used by pic14 */
+static char *_pic14_keywords[] =
+{
+  "at",
+  //"bit",
+  "code",
+  "critical",
+  "data",
+  "far",
+  "idata",
+  "interrupt",
+  "near",
+  "pdata",
+  "reentrant",
+  "sfr",
+  //"sbit",
+  "using",
+  "xdata",
+  "_data",
+  "_code",
+  "_generic",
+  "_near",
+  "_xdata",
+  "_pdata",
+  "_idata",
+  NULL
 };
 
 void  pCodeInitRegisters(void);
@@ -73,31 +73,31 @@ void pic14_assignRegisters (ebbIndex *);
 /* for an unknowned reason. - EEP */
 void pic14_emitDebuggerSymbol (char *);
 
-static int regParmFlg = 0;     /* determine if we can register a parameter */
+static int regParmFlg = 0;  /* determine if we can register a parameter */
 
 static void
 _pic14_init (void)
 {
-       asm_addTree (&asm_asxxxx_mapping);
-       memset (&pic14_options, 0, sizeof (pic14_options));
+  asm_addTree (&asm_asxxxx_mapping);
+  memset (&pic14_options, 0, sizeof (pic14_options));
 }
 
 static void
 _pic14_reset_regparm (void)
 {
-       regParmFlg = 0;
+  regParmFlg = 0;
 }
 
 static int
 _pic14_regparm (sym_link * l, bool reentrant)
 {
 /* for this processor it is simple
-       can pass only the first parameter in a register */
-       //if (regParmFlg)
-       //  return 0;
-       
-       regParmFlg++;// = 1;
-       return 1;
+  can pass only the first parameter in a register */
+  //if (regParmFlg)
+  //  return 0;
+  
+  regParmFlg++;// = 1;
+  return 1;
 }
 
 extern char *udata_section_name;
@@ -105,28 +105,26 @@ extern char *udata_section_name;
 static bool
 _pic14_parseOptions (int *pargc, char **argv, int *i)
 {
-       char buf[128];
-       
-       /* TODO: allow port-specific command line options to specify
-       * segment names here.
-       */
-       
-       /* This is a temporary hack, to solve problems with some processors
-       * that do not have udata section. It will be changed when a more
-       * robust solution is figured out -- VR 27-11-2003 FIXME
-       */
-       strcpy(buf, "--udata-section-name");
-       if(!strncmp(buf, argv[ *i ], strlen(buf))) {
-               if(strlen(argv[ *i ]) <= strlen(buf)+1) {
-                       fprintf(stderr, "WARNING: no `%s' entered\n", buf+2);
-                       exit(EXIT_FAILURE);
-               } else {
-                       udata_section_name = strdup( strchr(argv[*i], '=') + 1 );
-               }
-               return 1;
-       }
-
-       return FALSE;
+    /* TODO: allow port-specific command line options to specify
+    * segment names here.
+    */
+    
+    /* This is a temporary hack, to solve problems with some processors
+     * that do not have udata section. It will be changed when a more
+     * robust solution is figured out -- VR 27-11-2003 FIXME
+     */
+  if (!strcmp (argv[*i], OPTION_UDATA_SECTION_NAME))
+    {
+      if (udata_section_name) Safe_free(udata_section_name);
+      udata_section_name = Safe_strdup(getStringArg (OPTION_UDATA_SECTION_NAME, argv, i, *pargc));
+      return TRUE;
+    }
+  else if (!strcmp (argv[*i], OPTION_STACK_SIZE))
+    {
+      options.stack_size = getIntArg (OPTION_STACK_SIZE, argv, i, *pargc);
+      return TRUE;
+    }
+    return FALSE;
 }
 
 extern set *dataDirsSet;
@@ -164,64 +162,64 @@ _pic14_initPaths (void)
 static void
 _pic14_finaliseOptions (void)
 {
-       pCodeInitRegisters();
-       
-       port->mem.default_local_map = data;
-       port->mem.default_globl_map = data;
+  pCodeInitRegisters();
+  
+  port->mem.default_local_map = data;
+  port->mem.default_globl_map = data;
 #if 0
-       /* Hack-o-matic: if we are using the flat24 model,
-       * adjust pointer sizes.
-       */
-       if (options.model == MODEL_FLAT24)
-       {
-               
-               fprintf (stderr, "*** WARNING: you should use the '-mds390' option "
-                       "for DS80C390 support. This code generator is "
-                       "badly out of date and probably broken.\n");
-               
-               port->s.fptr_size = 3;
-               port->s.gptr_size = 4;
-               port->stack.isr_overhead++;     /* Will save dpx on ISR entry. */
+  /* Hack-o-matic: if we are using the flat24 model,
+  * adjust pointer sizes.
+  */
+  if (options.model == MODEL_FLAT24)
+  {
+    
+    fprintf (stderr, "*** WARNING: you should use the '-mds390' option "
+      "for DS80C390 support. This code generator is "
+      "badly out of date and probably broken.\n");
+    
+    port->s.fptr_size = 3;
+    port->s.gptr_size = 4;
+    port->stack.isr_overhead++; /* Will save dpx on ISR entry. */
 #if 1
-               port->stack.call_overhead++;    /* This acounts for the extra byte 
-                                                * of return addres on the stack.
-                                                * but is ugly. There must be a 
-                                                * better way.
-                                                */
+    port->stack.call_overhead++;  /* This acounts for the extra byte 
+                                     * of return addres on the stack.
+                                     * but is ugly. There must be a 
+                                     * better way.
+                                     */
 #endif
-               fReturn = fReturn390;
-               fReturnSize = 5;
-       }
-       
-       if (options.model == MODEL_LARGE)
-       {
-               port->mem.default_local_map = xdata;
-               port->mem.default_globl_map = xdata;
-       }
-       else
-       {
-               port->mem.default_local_map = data;
-               port->mem.default_globl_map = data;
-       }
-       
-       if (options.stack10bit)
-       {
-               if (options.model != MODEL_FLAT24)
-               {
-                       fprintf (stderr,
-                               "*** warning: 10 bit stack mode is only supported in flat24 model.\n");
-                       fprintf (stderr, "\t10 bit stack mode disabled.\n");
-                       options.stack10bit = 0;
-               }
-               else
-               {
-               /* Fixup the memory map for the stack; it is now in
-               * far space and requires a FPOINTER to access it.
-               */
-                       istack->fmap = 1;
-                       istack->ptrType = FPOINTER;
-               }
-       }
+    fReturn = fReturn390;
+    fReturnSize = 5;
+  }
+  
+  if (options.model == MODEL_LARGE)
+  {
+    port->mem.default_local_map = xdata;
+    port->mem.default_globl_map = xdata;
+  }
+  else
+  {
+    port->mem.default_local_map = data;
+    port->mem.default_globl_map = data;
+  }
+  
+  if (options.stack10bit)
+  {
+    if (options.model != MODEL_FLAT24)
+    {
+      fprintf (stderr,
+        "*** warning: 10 bit stack mode is only supported in flat24 model.\n");
+      fprintf (stderr, "\t10 bit stack mode disabled.\n");
+      options.stack10bit = 0;
+    }
+    else
+    {
+    /* Fixup the memory map for the stack; it is now in
+    * far space and requires a FPOINTER to access it.
+    */
+      istack->fmap = 1;
+      istack->ptrType = FPOINTER;
+    }
+  }
 #endif
 }
 
@@ -233,9 +231,9 @@ _pic14_setDefaultOptions (void)
 static const char *
 _pic14_getRegName (struct regs *reg)
 {
-       if (reg)
-               return reg->name;
-       return "err";
+  if (reg)
+    return reg->name;
+  return "err";
 }
 
 extern char *processor_base_name(void);
@@ -243,47 +241,47 @@ extern char *processor_base_name(void);
 static void
 _pic14_genAssemblerPreamble (FILE * of)
 {
-       char * name = processor_base_name();
-       
-       if(!name) {
-               
-               name = "16f877";
-               fprintf(stderr,"WARNING: No Pic has been selected, defaulting to %s\n",name);
-       }
-       
-       fprintf (of, "\tlist\tp=%s\n",name);
-       fprintf (of, "\tradix dec\n");
-       fprintf (of, "\tinclude \"p%s.inc\"\n",name);
+  char * name = processor_base_name();
+  
+  if(!name) {
+    
+    name = "16f877";
+    fprintf(stderr,"WARNING: No Pic has been selected, defaulting to %s\n",name);
+  }
+  
+  fprintf (of, "\tlist\tp=%s\n",name);
+  fprintf (of, "\tradix dec\n");
+  fprintf (of, "\tinclude \"p%s.inc\"\n",name);
 }
 
 /* Generate interrupt vector table. */
 static int
 _pic14_genIVT (struct dbuf_s * oBuf, symbol ** interrupts, int maxInterrupts)
 {
-       int i;
-       
-       if (options.model != MODEL_FLAT24)
-       {
-               /* Let the default code handle it. */
-               return FALSE;
-       }
-       
-       dbuf_printf (oBuf, "\t;ajmp\t__sdcc_gsinit_startup\n");
-       
-       /* now for the other interrupts */
-       for (i = 0; i < maxInterrupts; i++)
-       {
-               if (interrupts[i])
-               {
-                       dbuf_printf (oBuf, "\t;ljmp\t%s\n\t.ds\t4\n", interrupts[i]->rname);
-               }
-               else
-               {
-                       dbuf_printf (oBuf, "\t;reti\n\t.ds\t7\n");
-               }
-       }
-       
-       return TRUE;
+  int i;
+  
+  if (options.model != MODEL_FLAT24)
+  {
+    /* Let the default code handle it. */
+    return FALSE;
+  }
+  
+  dbuf_printf (oBuf, "\t;ajmp\t__sdcc_gsinit_startup\n");
+  
+  /* now for the other interrupts */
+  for (i = 0; i < maxInterrupts; i++)
+  {
+    if (interrupts[i])
+    {
+      dbuf_printf (oBuf, "\t;ljmp\t%s\n\t.ds\t4\n", interrupts[i]->rname);
+    }
+    else
+    {
+      dbuf_printf (oBuf, "\t;reti\n\t.ds\t7\n");
+    }
+  }
+  
+  return TRUE;
 }
 
 static bool
@@ -292,93 +290,93 @@ _hasNativeMulFor (iCode *ic, sym_link *left, sym_link *right)
 /*
 sym_link *test = NULL;
 value *val;
-       */
-       
-       //fprintf(stderr,"checking for native mult\n");
-       
-       if ( ic->op != '*')
-       {
-               return FALSE;
-       }
-       
-       /* multiply chars in-place */
-       if (getSize(left) == 1 && getSize(right) == 1)
-               return TRUE;
-       
-       /* use library functions for more complex maths */
-       return FALSE;
-
-       /*
-       if ( IS_LITERAL (left))
-       {
-       fprintf(stderr,"left is lit\n");
-       test = left;
-       val = OP_VALUE (IC_LEFT (ic));
-       }
-       else if ( IS_LITERAL (right))
-       {
-       fprintf(stderr,"right is lit\n");
-       test = left;
-       val = OP_VALUE (IC_RIGHT (ic));
-       }
-       else
-       {
-       fprintf(stderr,"oops, neither is lit so no\n");
-       return FALSE;
-       }
-       
-         if ( getSize (test) <= 2)
-         {
-         fprintf(stderr,"yep\n");
-         return TRUE;
-         }
-         fprintf(stderr,"nope\n");
-         
-               return FALSE;
-       */
+  */
+  
+  //fprintf(stderr,"checking for native mult\n");
+  
+  if ( ic->op != '*')
+  {
+    return FALSE;
+  }
+  
+  /* multiply chars in-place */
+  if (getSize(left) == 1 && getSize(right) == 1)
+    return TRUE;
+  
+  /* use library functions for more complex maths */
+  return FALSE;
+
+  /*
+  if ( IS_LITERAL (left))
+  {
+  fprintf(stderr,"left is lit\n");
+  test = left;
+  val = OP_VALUE (IC_LEFT (ic));
+  }
+  else if ( IS_LITERAL (right))
+  {
+  fprintf(stderr,"right is lit\n");
+  test = left;
+  val = OP_VALUE (IC_RIGHT (ic));
+  }
+  else
+  {
+  fprintf(stderr,"oops, neither is lit so no\n");
+  return FALSE;
+  }
+  
+    if ( getSize (test) <= 2)
+    {
+    fprintf(stderr,"yep\n");
+    return TRUE;
+    }
+    fprintf(stderr,"nope\n");
+    
+    return FALSE;
+  */
 }
 
 /* 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;
+  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;
+  /* 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;
+  return 0;
 }
 
 /** $1 is always the basename.
-$2 is always the output file.
-$3 varies
-$l is the list of extra options that should be there somewhere...
-MUST be terminated with a NULL.
+    $2 is always the output file.
+    $3 varies
+    $l is the list of extra options that should be there somewhere...
+    MUST be terminated with a NULL.
 */
 static const char *_linkCmd[] =
 {
-       "gplink", "$l", "-w", "-r", "-o \"$2\"", "\"$1\"", "$3", NULL
+  "gplink", "$l", "-w", "-r", "-o \"$2\"", "\"$1\"", "$3", NULL
 };
 
 static const char *_asmCmd[] =
 {
-       "gpasm", "$l", "-c", "\"$1.asm\"", NULL
-               
+  "gpasm", "$l", "-c", "\"$1.asm\"", NULL
+    
 };
 
 extern set *libFilesSet;
@@ -435,7 +433,7 @@ static void _pic14_do_link (void)
   if (!procName) {
      procName = "16f877";
   }
-       
+
   addSet(&libFilesSet, "libsdcc.lib");
   SNPRINTF(&temp[0], 128, "pic%s.lib", procName);
   addSet(&libFilesSet, temp);
@@ -454,128 +452,128 @@ static void _pic14_do_link (void)
 /* Globals */
 PORT pic_port =
 {
-       TARGET_ID_PIC,
-       "pic14",
-       "MCU pic",                      /* Target name */
-       "",                    /* Processor */
-       {
-               picglue,
-               TRUE,                   /* Emit glue around main */
-               MODEL_SMALL | MODEL_LARGE | MODEL_FLAT24,
-               MODEL_SMALL
-       },
-       {
-               _asmCmd,
-               NULL,
-               NULL,
-               NULL,
-               //"-plosgffc",          /* Options with debug */
-               //"-plosgff",           /* Options without debug */
-               0,
-               ".asm",
-               NULL                    /* no do_assemble function */
-       },
-       {
-               _linkCmd,
-               NULL,
-               _pic14_do_link,         /* own do link function */
-               ".o",
-               0
-       },
-       {
-               _defaultRules
-       },
-       {
-               /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
-               1, 2, 2, 4, 2, 2, 3, 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)
-                */
-       },
-       /* tags for generic pointers */
-       { 0x00, 0x00, 0x00, 0x80 },             /* far, near, xstack, code */
-       {
-               "XSEG    (XDATA)",
-               "STACK   (DATA)",
-               "code",
-               "DSEG    (DATA)",
-               "ISEG    (DATA)",
-               NULL, /* pdata */
-               "XSEG    (XDATA)",
-               "BSEG    (BIT)",
-               "RSEG    (DATA)",
-               "GSINIT  (CODE)",
-               "udata_ovr",
-               "GSFINAL (CODE)",
-               "HOME    (CODE)",
-               NULL, // xidata
-               NULL, // xinit
-               "CONST   (CODE)",               // const_name - const data (code or not)
-               "CABS    (ABS,CODE)",   // cabs_name - const absolute data (code or not)
-               "XABS    (ABS,XDATA)",  // xabs_name - absolute xdata
-               "IABS    (ABS,DATA)",   // iabs_name - absolute data
-               NULL,
-               NULL,
-               1        // code is read only
-       },
-       { NULL, NULL },
-       {
-               +1, 1, 4, 1, 1, 0
-       },
-               /* pic14 has an 8 bit mul */
-       {
-               1, -1
-       },
-       {
-               pic14_emitDebuggerSymbol
-       },
-       {
-               255/3,      /* maxCount */
-               3,          /* sizeofElement */
-               /* The rest of these costs are bogus. They approximate */
-               /* the behavior of src/SDCCicode.c 1.207 and earlier.  */
-               {4,4,4},    /* sizeofMatchJump[] */
-               {0,0,0},    /* sizeofRangeCompare[] */
-               0,          /* sizeofSubtract */
-               3,          /* sizeofDispatch */
-       },
-       "_",
-       _pic14_init,
-       _pic14_parseOptions,
-       _pic14_poptions,
-       _pic14_initPaths,
-       _pic14_finaliseOptions,
-       _pic14_setDefaultOptions,
-       pic14_assignRegisters,
-       _pic14_getRegName,
-       _pic14_keywords,
-       _pic14_genAssemblerPreamble,
-       NULL,                           /* no genAssemblerEnd */
-       _pic14_genIVT,
-       NULL, // _pic14_genXINIT
-       NULL,                           /* genInitStartup */
-       _pic14_reset_regparm,
-       _pic14_regparm,
-       NULL,                           /* process a pragma */
-       NULL,
-       _hasNativeMulFor,
-       hasExtBitOp,                    /* hasExtBitOp */
-       oclsExpense,                    /* oclsExpense */
-       FALSE,
-//     TRUE,                           /* little endian */
-       FALSE,                          /* little endian - PIC code enumlates big endian */
-       0,                              /* leave lt */
-       0,                              /* leave gt */
-       1,                              /* transform <= to ! > */
-       1,                              /* transform >= to ! < */
-       1,                              /* transform != to !(a == b) */
-       0,                              /* leave == */
-       FALSE,                        /* No array initializer support. */
-       0,                            /* no CSE cost estimation yet */
-       NULL,                   /* no builtin functions */
-       GPOINTER,                       /* treat unqualified pointers as "generic" pointers */
-       1,                              /* reset labelKey to 1 */
-       1,                              /* globals & local static allowed */
-       PORT_MAGIC
+  TARGET_ID_PIC,
+  "pic14",
+  "MCU pic",        /* Target name */
+  "",               /* Processor */
+  {
+    picglue,
+    TRUE,     /* Emit glue around main */
+    MODEL_SMALL | MODEL_LARGE | MODEL_FLAT24,
+    MODEL_SMALL
+  },
+  {
+    _asmCmd,
+    NULL,
+    NULL,
+    NULL,
+    //"-plosgffc",  /* Options with debug */
+    //"-plosgff",   /* Options without debug */
+    0,
+    ".asm",
+    NULL            /* no do_assemble function */
+  },
+  {
+    _linkCmd,
+    NULL,
+    _pic14_do_link, /* own do link function */
+    ".o",
+    0
+  },
+  {
+    _defaultRules
+  },
+  {
+    /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
+    1, 2, 2, 4, 2, 2, 3, 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)
+     */
+  },
+  /* tags for generic pointers */
+  { 0x00, 0x00, 0x00, 0x80 },   /* far, near, xstack, code */
+  {
+    "XSEG    (XDATA)",
+    "STACK   (DATA)",
+    "code",
+    "DSEG    (DATA)",
+    "ISEG    (DATA)",
+    NULL, /* pdata */
+    "XSEG    (XDATA)",
+    "BSEG    (BIT)",
+    "RSEG    (DATA)",
+    "GSINIT  (CODE)",
+    "udata_ovr",
+    "GSFINAL (CODE)",
+    "HOME       (CODE)",
+    NULL, // xidata
+    NULL, // xinit
+    "CONST   (CODE)",   // const_name - const data (code or not)
+    "CABS    (ABS,CODE)", // cabs_name - const absolute data (code or not)
+    "XABS    (ABS,XDATA)",  // xabs_name - absolute xdata
+    "IABS    (ABS,DATA)", // iabs_name - absolute data
+    NULL,
+    NULL,
+    1        // code is read only
+  },
+  { NULL, NULL },
+  {
+    +1, 1, 4, 1, 1, 0
+  },
+    /* pic14 has an 8 bit mul */
+  {
+    1, -1
+  },
+  {
+    pic14_emitDebuggerSymbol
+  },
+  {
+    255/3,      /* maxCount */
+    3,          /* sizeofElement */
+    /* The rest of these costs are bogus. They approximate */
+    /* the behavior of src/SDCCicode.c 1.207 and earlier.  */
+    {4,4,4},    /* sizeofMatchJump[] */
+    {0,0,0},    /* sizeofRangeCompare[] */
+    0,          /* sizeofSubtract */
+    3,          /* sizeofDispatch */
+  },
+  "_",
+  _pic14_init,
+  _pic14_parseOptions,
+  _pic14_poptions,
+  _pic14_initPaths,
+  _pic14_finaliseOptions,
+  _pic14_setDefaultOptions,
+  pic14_assignRegisters,
+  _pic14_getRegName,
+  _pic14_keywords,
+  _pic14_genAssemblerPreamble,
+  NULL,         /* no genAssemblerEnd */
+  _pic14_genIVT,
+  NULL, // _pic14_genXINIT
+  NULL,         /* genInitStartup */
+  _pic14_reset_regparm,
+  _pic14_regparm,
+  NULL,         /* process a pragma */
+  NULL,
+  _hasNativeMulFor,
+  hasExtBitOp,  /* hasExtBitOp */
+  oclsExpense,  /* oclsExpense */
+  FALSE,
+//  TRUE,       /* little endian */
+  FALSE,        /* little endian - PIC code enumlates big endian */
+  0,            /* leave lt */
+  0,            /* leave gt */
+  1,            /* transform <= to ! > */
+  1,            /* transform >= to ! < */
+  1,            /* transform != to !(a == b) */
+  0,            /* leave == */
+  FALSE,        /* No array initializer support. */
+  0,            /* no CSE cost estimation yet */
+  NULL,         /* no builtin functions */
+  GPOINTER,     /* treat unqualified pointers as "generic" pointers */
+  1,            /* reset labelKey to 1 */
+  1,            /* globals & local static allowed */
+  PORT_MAGIC
 };
index 64984af6b6bf5e15c93731835d7e324591863925..23089afe534d22690a8ad91b345c24ee6638c494 100644 (file)
@@ -37,6 +37,7 @@
 #define OPTION_CALLEE_SAVES_BC "--callee-saves-bc"
 #define OPTION_PORTMODE        "--portmode="
 #define OPTION_ASM             "--asm="
+#define OPTION_NO_STD_CRT0     "--no-std-crt0"
 
 
 static char _z80_defaultRules[] =
@@ -56,20 +57,22 @@ Z80_OPTS z80_opts;
 static OPTION _z80_options[] =
   {
     { 0, OPTION_CALLEE_SAVES_BC, &z80_opts.calleeSavesBC, "Force a called function to always save BC" },
-    { 0, OPTION_PORTMODE,        NULL,                    "Determine PORT I/O mode (z80/z180)" },
-    { 0, OPTION_ASM,             NULL,                    "Define assembler name (rgbds/asxxxx/isas/z80asm)" },
-    { 0, OPTION_CODE_SEG,        NULL,                    "<name> use this name for the code segment" },
-    { 0, OPTION_CONST_SEG,       NULL,                    "<name> use this name for the const segment" },
+    { 0, OPTION_PORTMODE,        NULL, "Determine PORT I/O mode (z80/z180)" },
+    { 0, OPTION_ASM,             NULL, "Define assembler name (rgbds/asxxxx/isas/z80asm)" },
+    { 0, OPTION_CODE_SEG,        NULL, "<name> use this name for the code segment" },
+    { 0, OPTION_CONST_SEG,       NULL, "<name> use this name for the const segment" },
+    { 0, OPTION_NO_STD_CRT0,     &options.no_std_crt0, "For the z80/gbz80 do not link default crt0.o"},
     { 0, NULL }
   };
 
 static OPTION _gbz80_options[] = 
   {
-    { 0, OPTION_BO,              NULL,                    "<num> use code bank <num>" },
-    { 0, OPTION_BA,              NULL,                    "<num> use data bank <num>" },
+    { 0, OPTION_BO,              NULL, "<num> use code bank <num>" },
+    { 0, OPTION_BA,              NULL, "<num> use data bank <num>" },
     { 0, OPTION_CALLEE_SAVES_BC, &z80_opts.calleeSavesBC, "Force a called function to always save BC" },
-    { 0, OPTION_CODE_SEG,        NULL,                    "<name> use this name for the code segment"  },
-    { 0, OPTION_CONST_SEG,       NULL,                    "<name> use this name for the const segment" },
+    { 0, OPTION_CODE_SEG,        NULL, "<name> use this name for the code segment"  },
+    { 0, OPTION_CONST_SEG,       NULL, "<name> use this name for the const segment" },
+    { 0, OPTION_NO_STD_CRT0,     &options.no_std_crt0, "For the z80/gbz80 do not link default crt0.o"},
     { 0, NULL }
   };