* src/mcs51/peeph.def: added 177.i (mov from a is slightly cheaper)
[fw/sdcc] / src / mcs51 / main.c
index c1b18ea0b34b13abacb85fd877a23162dc320b7c..b1676b91ea18d723d6c8503fe254b967bba688d5 100644 (file)
@@ -8,6 +8,7 @@
 #include "main.h"
 #include "ralloc.h"
 #include "gen.h"
+#include "dbuf_string.h"
 #include "../SDCCutil.h"
 
 static char _defaultRules[] =
@@ -15,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[] =
 {
@@ -112,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;
 }
 
@@ -175,26 +192,26 @@ _mcs51_genAssemblerPreamble (FILE * of)
 
 /* Generate interrupt vector table. */
 static int
-_mcs51_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
+_mcs51_genIVT (struct dbuf_s * oBuf, symbol ** interrupts, int maxInterrupts)
 {
   int i;
 
-  fprintf (of, "\tljmp\t__sdcc_gsinit_startup\n");
+  dbuf_printf (oBuf, "\tljmp\t__sdcc_gsinit_startup\n");
 
   /* now for the other interrupts */
   for (i = 0; i < maxInterrupts; i++)
     {
       if (interrupts[i])
         {
-          fprintf (of, "\tljmp\t%s\n", interrupts[i]->rname);
+          dbuf_printf (oBuf, "\tljmp\t%s\n", interrupts[i]->rname);
           if ( i != maxInterrupts - 1 )
-            fprintf (of, "\t.ds\t5\n");
+            dbuf_printf (oBuf, "\t.ds\t5\n");
         }
       else
         {
-          fprintf (of, "\treti\n");
+          dbuf_printf (oBuf, "\treti\n");
           if ( i != maxInterrupts - 1 )
-            fprintf (of, "\t.ds\t7\n");
+            dbuf_printf (oBuf, "\t.ds\t7\n");
         }
     }
   return TRUE;
@@ -590,7 +607,7 @@ asmLineNodeFromLineNode (lineNode *ln)
   asmLineNode *aln = newAsmLineNode();
   char *op, op1[256], op2[256];
   int opsize;
-  const unsigned char *p;
+  const char *p;
   char inst[8];
   mcs51opcodedata *opdat;
 
@@ -729,12 +746,15 @@ PORT mcs51_port =
     _defaultRules,
     getInstructionSize,
     getRegsRead,
-    getRegsWritten
+    getRegsWritten,
+    mcs51DeadMove
   },
   {
     /* 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 */
   {
     "XSTK    (PAG,XDATA)",      // xstack_name
     "STACK   (DATA)",           // istack_name
@@ -752,6 +772,9 @@ PORT mcs51_port =
     "XISEG   (XDATA)",          // xidata_name - initialized xdata   initialized xdata
     "XINIT   (CODE)",           // xinit_name - 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
@@ -783,7 +806,7 @@ PORT mcs51_port =
   "_",
   _mcs51_init,
   _mcs51_parseOptions,
-  NULL,
+  _mcs51_options,
   NULL,
   _mcs51_finaliseOptions,
   _mcs51_setDefaultOptions,