* as/mcs51/asexpr.c (expr): disabled warning "not in .flat24 mode",
[fw/sdcc] / src / xa51 / main.c
index 05ba1c833400461919d8e0f7c75d39947e0ace1a..8030dbddf546d0251078e59f60b72b7ab2a91fe3 100755 (executable)
@@ -1,9 +1,7 @@
-/** @file main.c
-    xa51 specific general functions.
-
-    Note that mlh prepended _xa51_ on the static functions.  Makes
-    it easier to set a breakpoint using the debugger.
+/* @file main.c
+   xa51 specific general functions.
 */
+
 #include "common.h"
 #include "main.h"
 #include "ralloc.h"
@@ -44,13 +42,18 @@ static char *_xa51_keywords[] =
   NULL
 };
 
-extern int rewinds;
-void   _xa51_genAssemblerEnd () {
+/* rewinds declared in asm.c, function printCLine().
+ * Currently commented out.
+ *
+ * extern int rewinds;
+ */
+void   _xa51_genAssemblerEnd (FILE * of)
+{
   //fprintf (stderr, "Did %d rewind%c for c-line in asm comments\n", rewinds,
   //rewinds==1 ? '\0' : 's');
 }
 
-void xa51_assignRegisters (eBBlock ** ebbs, int count);
+void xa51_assignRegisters (ebbIndex *);
 
 static int regParmFlg = 0;     /* determine if we can register a parameter */
 
@@ -61,7 +64,7 @@ _xa51_init (void)
 }
 
 static void
-_xa51_reset_regparm ()
+_xa51_reset_regparm (void)
 {
   regParmFlg = 0;
 }
@@ -91,8 +94,13 @@ _xa51_parseOptions (int *pargc, char **argv, int *i)
 static void
 _xa51_finaliseOptions (void)
 {
+  fprintf (stderr, "*** WARNING *** The XA51 port isn't yet complete\n");
   port->mem.default_local_map = istack;
   port->mem.default_globl_map = xdata;
+  if (options.model!=MODEL_PAGE0) {
+    fprintf (stderr, "-mxa51 only supports --model-page0\n");
+    exit (1);
+  }
 }
 
 static void
@@ -102,6 +110,7 @@ _xa51_setDefaultOptions (void)
   options.intlong_rent=1;
   options.float_rent=1;
   options.stack_loc=0x100;
+  options.data_loc=0;
 }
 
 static const char *
@@ -139,19 +148,19 @@ _xa51_genAssemblerPreamble (FILE * of)
   symbol *mainExists=newSymbol("main", 0);
   mainExists->block=0;
 
-  fprintf (of, "_errno\tsfr\t0x00; to keep the fp-lib's happy for now\n\n");
-
   if ((mainExists=findSymWithLevel(SymbolTab, mainExists))) {
-    fprintf (of, "\t.area CSEG\t(CODE)\n");
+    fprintf (of, "\t.area GSINIT\t(CODE)\n");
     fprintf (of, "__interrupt_vect:\n");
     fprintf (of, "\t.dw\t0x8f00\n");
     fprintf (of, "\t.dw\t__sdcc_gsinit_startup\n");
     fprintf (of, "\n");
     fprintf (of, "__sdcc_gsinit_startup:\n");
-    fprintf (of, "\tmov.b\t_SCR,#0x01\t; page zero mode\n");
+    fprintf (of, ";\tmov.b\t_SCR,#0x01\t; page zero mode\n");
+    fprintf (of, "\t.db 0x96,0x48,0x40,0x01\n");
     fprintf (of, "\tmov\tr7,#0x%04x\n", options.stack_loc);
     fprintf (of, "\tcall\t_external_startup\n");
     _xa51_genXINIT(of);
+    fprintf (of, "\t.area CSEG\t(CODE)\n");
     fprintf (of, "\tcall\t_main\n");
     fprintf (of, "\treset\t;main should not return\n");
   }
@@ -183,7 +192,30 @@ static bool cseCostEstimation (iCode *ic, iCode *pdic)
     return 1;
 }
 
-#if 0
+/* Indicate which extended bit operations this port supports */
+static bool
+hasExtBitOp (int op, int size)
+{
+  if (op == RRC
+      || op == RLC
+      || op == GETHBIT
+     )
+    return TRUE;
+  else
+    return FALSE;
+}
+
+/* Indicate the expense of an access to an output storage class */
+static int
+oclsExpense (struct memmap *oclass)
+{
+  if (IN_FARSPACE(oclass))
+    return 1;
+    
+  return 0;
+}
+
+
 /** $1 is always the basename.
     $2 is always the output file.
     $3 varies
@@ -192,14 +224,13 @@ static bool cseCostEstimation (iCode *ic, iCode *pdic)
 */
 static const char *_linkCmd[] =
 {
-  "{bindir}{sep}aslink", "-nf", "$1", NULL
+  "xa_link", "", "\"$1\"", NULL
 };
-#endif
 
 /* $3 is replaced by assembler.debug_opts resp. port->assembler.plain_opts */
 static const char *_asmCmd[] =
 {
-  "xa_asm", "$l", "$3", "$1.xa", NULL
+  "xa_rasm", "$l", "$3", "\"$1.asm\"", NULL
 };
 
 /* Globals */
@@ -208,10 +239,12 @@ PORT xa51_port =
   TARGET_ID_XA51,
   "xa51",
   "MCU 80C51XA",                       /* Target name */
+  NULL,                                /* Processor name */
   {
+    glue,
     FALSE,                     /* Emit glue around main */
-    MODEL_LARGE,
-    MODEL_LARGE
+    MODEL_PAGE0,
+    MODEL_PAGE0
   },
   {
     _asmCmd,
@@ -219,14 +252,15 @@ PORT xa51_port =
     "",                                /* Options with debug */
     "",                                /* Options without debug */
     0,
-    ".xa",
+    ".asm",
     NULL                       /* no do_assemble function */
   },
   {
-    NULL, //_linkCmd,
+    _linkCmd,
     NULL,
-    xa_link,
-    ".rel"
+    NULL,
+    ".rel",
+    1
   },
   {
     _defaultRules
@@ -241,6 +275,7 @@ PORT xa51_port =
     "CSEG    (CODE)",
     "DSEG    (DATA)",
     NULL, //"ISEG    (DATA)",
+    NULL, //"PSEG    (PAG,XDATA)",
     "XSEG    (XDATA)",
     "BSEG    (BIT)",
     NULL, //"RSEG    (DATA)",
@@ -250,15 +285,17 @@ PORT xa51_port =
     "HOME    (CODE)",
     "XISEG   (XDATA)", // initialized xdata
     "XINIT   (CODE)", // a code copy of xiseg
+    "CONST   (CODE)",          // const_name - const data (code or not)
     NULL, // default local map
     NULL, // default global map
     1
   },
+  { NULL, NULL },
   {
     -1, // stack grows down
     0, // bank overhead NUY
-    6, // isr overhead
-    4, // function call overhead
+    4, // isr overhead, page zero mode
+    2, // function call overhead, page zero mode
     0, // reentrant overhead NUY
     0 // banked overhead NUY
   },
@@ -266,9 +303,24 @@ PORT xa51_port =
   {
     2, -2
   },
+  {
+    xa51_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 */
+  },
   "_",
   _xa51_init,
   _xa51_parseOptions,
+  NULL,
+  NULL,
   _xa51_finaliseOptions,
   _xa51_setDefaultOptions,
   xa51_assignRegisters,
@@ -278,17 +330,21 @@ PORT xa51_port =
   _xa51_genAssemblerEnd,
   _xa51_genIVT,
   _xa51_genXINIT,
+  NULL,                        /* genInitStartup */
   _xa51_reset_regparm,
   _xa51_regparm,
   NULL, // process_pragma()
   NULL, // getMangledFunctionName()
   NULL, // hasNativeMulFor()
+  hasExtBitOp,                 /* hasExtBitOp */
+  oclsExpense,                 /* oclsExpense */
   TRUE, // use_dw_for_init
+  TRUE,                                /* little endian */
   0,                           /* leave lt */
   0,                           /* leave gt */
-  0,                           /* transform <= to ! > */
-  0,                           /* transform >= to ! < */
-  0,                           /* transform != to !(a == b) */
+  1,                           /* transform <= to ! > */
+  1,                           /* transform >= to ! < */
+  1,                           /* transform != to !(a == b) */
   0,                           /* leave == */
   FALSE,                        /* No array initializer support. */
   cseCostEstimation,