Added port "tiniNative"
[fw/sdcc] / src / SDCCglue.c
index fd6d396707f966e72789f7f5ec49b4c13d50815e..e100f5bb39ba794a02d58408ec06a94ed234db47 100644 (file)
@@ -232,12 +232,8 @@ emitRegularMap (memmap * map, bool addPublics, bool arFlag)
       /* if it has an initial value then do it only if
          it is a global variable */
       if (sym->ival && sym->level == 0) {
-       // can we copy xidata from xinit?
-       if (port->genXINIT &&
-           SPEC_OCLS(sym->etype)==xdata &&
-           !SPEC_ABSA(sym->etype)) {
-
-         // create a new "XINIT (CODE)" symbol
+       if (SPEC_OCLS(sym->etype)==xidata) {
+         // create a new "XINIT (CODE)" symbol, that will be emitted later
          newSym=copySymbol (sym);
          SPEC_OCLS(newSym->etype)=xinit;
          sprintf (newSym->name, "_xinit_%s", sym->name);
@@ -249,11 +245,6 @@ emitRegularMap (memmap * map, bool addPublics, bool arFlag)
          // add it to the "XINIT (CODE)" segment
          addSet(&xinit->syms, newSym);
 
-         // move sym from "XSEG (XDATA)" to "XISEG (XDATA)" segment
-         //deleteSetItem(&xdata->syms, sym);
-         addSet(&xidata->syms, sym);
-         SPEC_OCLS(sym->etype)=xidata;
-
          //fprintf (stderr, "moved %s from xdata to xidata\n", sym->rname);
          
        } else {
@@ -566,6 +557,10 @@ printIvalType (symbol *sym, sym_link * type, initList * ilist, FILE * oFile)
        }
 
        val = list2val (ilist);
+       if (val->type != type) {
+         val = valCastLiteral(type, floatFromVal(val));
+       }
+       
        switch (getSize (type)) {
        case 1:
                if (!val)
@@ -865,7 +860,7 @@ printIvalCharPtr (symbol * sym, sym_link * type, value * val, FILE * oFile)
     }
   else
     {
-      /* What is this case? Are these pointers? */
+      // these are literals assigned to pointers
       switch (size)
        {
        case 1:
@@ -879,14 +874,20 @@ printIvalCharPtr (symbol * sym, sym_link * type, value * val, FILE * oFile)
                      aopLiteral (val, 0), aopLiteral (val, 1));
          break;
        case 3:
-         werror (E_LITERAL_GENERIC);
+         // mcs51 generic pointer
+         if (floatFromVal(val)!=0) {
+           werror (E_LITERAL_GENERIC);
+         }
          fprintf (oFile, "\t.byte %s,%s,%s\n",
                   aopLiteral (val, 0), 
                   aopLiteral (val, 1),
                   aopLiteral (val, 2));
          break;
        case 4:
-         werror (E_LITERAL_GENERIC);
+         // ds390 generic pointer
+         if (floatFromVal(val)!=0) {
+           werror (E_LITERAL_GENERIC);
+         }
          fprintf (oFile, "\t.byte %s,%s,%s,%s\n",
                   aopLiteral (val, 0), 
                   aopLiteral (val, 1), 
@@ -1028,7 +1029,7 @@ emitStaticSeg (memmap * map, FILE * out)
 {
   symbol *sym;
 
-  fprintf(out, "\t.area\t%s\n", map->sname);
+  /* fprintf(out, "\t.area\t%s\n", map->sname); */
 
   /* for all variables in this segment do */
   for (sym = setFirstItem (map->syms); sym;
@@ -1125,6 +1126,7 @@ emitMaps ()
 
   emitStaticSeg (statsg, code->oFile);
   if (port->genXINIT) {
+    fprintf (code->oFile, "\t.area\t%s\n", xinit->sname);
     emitStaticSeg (xinit, code->oFile);
   }
   inInitMode--;