fixed width array of pointers replaced with sets;
[fw/sdcc] / src / mcs51 / main.c
index b91a622c9c9b773258744fcf2de2f431a2fcddac..52048d1bf52d69cbb0e6f8c4cd776ae9082df085 100644 (file)
@@ -8,6 +8,7 @@
 #include "main.h"
 #include "ralloc.h"
 #include "gen.h"
+#include "../SDCCutil.h"
 
 static char _defaultRules[] =
 {
@@ -64,13 +65,31 @@ _mcs51_reset_regparm ()
 static int
 _mcs51_regparm (sym_link * l)
 {
-  /* for this processor it is simple
-     can pass only the first parameter in a register */
-  if (regParmFlg)
-    return 0;
+    if (options.parms_in_bank1 == 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 */
+        remain = regParmFlg - 4;
+       if (size > (8 - remain)) {
+           regParmFlg = 12 ;
+           return 0;
+       }
+       regParmFlg += size ;
+       return regParmFlg - size + 1;   
+    }
 }
 
 static bool
@@ -85,6 +104,10 @@ _mcs51_parseOptions (int *pargc, char **argv, int *i)
 static void
 _mcs51_finaliseOptions (void)
 {
+  if (options.noXinitOpt) {
+    port->genXINIT=0;
+  }
+
   if (options.model == MODEL_LARGE) {
       port->mem.default_local_map = xdata;
       port->mem.default_globl_map = xdata;
@@ -94,6 +117,10 @@ _mcs51_finaliseOptions (void)
       port->mem.default_local_map = data;
       port->mem.default_globl_map = data;
     }
+
+  if (options.parms_in_bank1) {
+      addSet(&preArgvSet, Safe_strdup("-DSDCC_PARMS_IN_BANK1"));
+  }
 }
 
 static void
@@ -112,6 +139,11 @@ _mcs51_getRegName (struct regs *reg)
 static void
 _mcs51_genAssemblerPreamble (FILE * of)
 {
+    if (options.parms_in_bank1) {
+       int i ;
+       for (i=0; i < 8 ; i++ )
+           fprintf (of,"b1_%d = 0x%x \n",i,8+i);
+    }
 }
 
 /* Generate interrupt vector table. */
@@ -183,13 +215,13 @@ static bool cseCostEstimation (iCode *ic, iCode *pdic)
 */
 static const char *_linkCmd[] =
 {
-  "{bindir}{sep}aslink", "-nf", "$1", NULL
+  "aslink", "-nf", "\"$1\"", NULL
 };
 
 /* $3 is replaced by assembler.debug_opts resp. port->assembler.plain_opts */
 static const char *_asmCmd[] =
 {
-  "asx8051", "$l", "$3", "$1.asm", NULL
+  "asx8051", "$l", "$3", "\"$1.asm\"", NULL
 };
 
 /* Globals */
@@ -198,6 +230,7 @@ PORT mcs51_port =
   TARGET_ID_MCS51,
   "mcs51",
   "MCU 8051",                  /* Target name */
+  NULL,                                /* Processor name */
   {
     TRUE,                      /* Emit glue around main */
     MODEL_SMALL | MODEL_LARGE,
@@ -245,7 +278,7 @@ PORT mcs51_port =
     1
   },
   {
-    +1, 1, 4, 1, 1, 0
+    +1, 0, 4, 1, 1, 0
   },
     /* mcs51 has an 8 bit mul */
   {
@@ -254,6 +287,7 @@ PORT mcs51_port =
   "_",
   _mcs51_init,
   _mcs51_parseOptions,
+  NULL,
   _mcs51_finaliseOptions,
   _mcs51_setDefaultOptions,
   mcs51_assignRegisters,