* doc/cdbfile.html: removed, replaced by cdbfileformat.lyx
[fw/sdcc] / src / xa51 / main.c
index 60cb2d10caa419f8c06ba099d991457f3a47db2d..330e613e368df9b16bebd3c7f2a0064efa7f654e 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"
@@ -91,8 +89,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 +105,7 @@ _xa51_setDefaultOptions (void)
   options.intlong_rent=1;
   options.float_rent=1;
   options.stack_loc=0x100;
+  options.data_loc=0;
 }
 
 static const char *
@@ -140,16 +144,18 @@ _xa51_genAssemblerPreamble (FILE * of)
   mainExists->block=0;
 
   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");
   }
@@ -181,7 +187,6 @@ static bool cseCostEstimation (iCode *ic, iCode *pdic)
     return 1;
 }
 
-#if 0
 /** $1 is always the basename.
     $2 is always the output file.
     $3 varies
@@ -190,14 +195,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_rasm", "$l", "$3", "$1.xa", NULL
+  "xa_rasm", "$l", "$3", "$1.asm", NULL
 };
 
 /* Globals */
@@ -206,10 +210,11 @@ PORT xa51_port =
   TARGET_ID_XA51,
   "xa51",
   "MCU 80C51XA",                       /* Target name */
+  NULL,                                /* Processor name */
   {
     FALSE,                     /* Emit glue around main */
-    MODEL_LARGE,
-    MODEL_LARGE
+    MODEL_PAGE0,
+    MODEL_PAGE0
   },
   {
     _asmCmd,
@@ -217,13 +222,13 @@ PORT xa51_port =
     "",                                /* Options with debug */
     "",                                /* Options without debug */
     0,
-    ".xa",
+    ".asm",
     NULL                       /* no do_assemble function */
   },
   {
-    NULL, //_linkCmd,
+    _linkCmd,
+    NULL,
     NULL,
-    xa_link,
     ".rel"
   },
   {
@@ -267,6 +272,7 @@ PORT xa51_port =
   "_",
   _xa51_init,
   _xa51_parseOptions,
+  NULL,
   _xa51_finaliseOptions,
   _xa51_setDefaultOptions,
   xa51_assignRegisters,
@@ -284,9 +290,9 @@ PORT xa51_port =
   TRUE, // use_dw_for_init
   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,