* src/SDCCast.c (createIvalStruct, createIvalArray, createIvalPtr, createIval): imple...
[fw/sdcc] / src / SDCCglue.c
index acb2d34284eb95807086c4d0b5e9d1bbddc13be3..78da017738a22143ee51f7268be971a887286f92 100644 (file)
@@ -361,7 +361,7 @@ emitRegularMap (memmap * map, bool addPublics, bool arFlag)
                    SPEC_ADDR (sym->etype));
         }
       else {
-        int size = getAllocSize (sym->type);
+        int size = getSize (sym->type) + sym->flexArrayLength;
         if (size==0) {
           werrorfl (sym->fileDef, sym->lineDef, E_UNKNOWN_SIZE, sym->name);
         }
@@ -1319,7 +1319,7 @@ emitMaps (void)
      data, idata & bit & xdata */
   emitRegularMap (data, TRUE, TRUE);
   emitRegularMap (idata, TRUE, TRUE);
-  emitRegularMap (bit, TRUE, FALSE);
+  emitRegularMap (bit, TRUE, TRUE);
   emitRegularMap (pdata, TRUE, TRUE);
   emitRegularMap (xdata, TRUE, TRUE);
   if (port->genXINIT) {
@@ -1330,6 +1330,9 @@ emitMaps (void)
   emitRegularMap (home, TRUE, FALSE);
   emitRegularMap (code, TRUE, FALSE);
 
+  if (options.const_seg) {
+    tfprintf (code->oFile, "\t!area\n", options.const_seg);
+  }
   emitStaticSeg (statsg, code->oFile);
   if (port->genXINIT) {
     tfprintf (code->oFile, "\t!area\n", xinit->sname);
@@ -1375,7 +1378,7 @@ createInterruptVect (FILE * vFile)
       return;
     }
 
-  tfprintf (vFile, "\t!areacode\n", CODE_NAME);
+  tfprintf (vFile, "\t!areacode\n", HOME_NAME);
   fprintf (vFile, "__interrupt_vect:\n");
 
 
@@ -1559,7 +1562,7 @@ spacesToUnderscores (char *dest, const char *src, size_t len)
 
   --len;
   for (p = dest, i = 0; *src != '\0' && i < len; ++src, ++i) {
-    *p++ = isspace(*src) ? '_' : *src;
+    *p++ = isspace((unsigned char)*src) ? '_' : *src;
   }
   *p = '\0';
 
@@ -1595,7 +1598,7 @@ glue (void)
     cdbStructBlock (0);
 
   vFile = tempfile ();
-  /* PENDING: this isnt the best place but it will do */
+  /* PENDING: this isn't the best place but it will do */
   if (port->general.glue_up_main)
     {
       /* create the interrupt vector table */
@@ -1691,7 +1694,7 @@ glue (void)
     {
       /* copy the sbit segment */
       fprintf (asmFile, "%s", iComments2);
-      fprintf (asmFile, "; special function bits \n");
+      fprintf (asmFile, "; special function bits\n");
       fprintf (asmFile, "%s", iComments2);
       copyFile (asmFile, sfrbit->oFile);
   
@@ -1699,16 +1702,32 @@ glue (void)
       if(RegBankUsed[0]||RegBankUsed[1]||RegBankUsed[2]||RegBankUsed[3])
       {
          fprintf (asmFile, "%s", iComments2);
-         fprintf (asmFile, "; overlayable register banks \n");
+         fprintf (asmFile, "; overlayable register banks\n");
          fprintf (asmFile, "%s", iComments2);
          if(RegBankUsed[0])
-            fprintf (asmFile, "\t.area REG_BANK_0\t(REL,OVR,DATA)\n\t.ds 8\n");
+           fprintf (asmFile, "\t.area REG_BANK_0\t(REL,OVR,DATA)\n\t.ds 8\n");
          if(RegBankUsed[1]||options.parms_in_bank1)
-            fprintf (asmFile, "\t.area REG_BANK_1\t(REL,OVR,DATA)\n\t.ds 8\n");
+           fprintf (asmFile, "\t.area REG_BANK_1\t(REL,OVR,DATA)\n\t.ds 8\n");
          if(RegBankUsed[2])
-            fprintf (asmFile, "\t.area REG_BANK_2\t(REL,OVR,DATA)\n\t.ds 8\n");
+           fprintf (asmFile, "\t.area REG_BANK_2\t(REL,OVR,DATA)\n\t.ds 8\n");
          if(RegBankUsed[3])
-            fprintf (asmFile, "\t.area REG_BANK_3\t(REL,OVR,DATA)\n\t.ds 8\n");
+           fprintf (asmFile, "\t.area REG_BANK_3\t(REL,OVR,DATA)\n\t.ds 8\n");
+      }
+      if(BitBankUsed)
+      {
+         fprintf (asmFile, "%s", iComments2);
+         fprintf (asmFile, "; overlayable bit register bank\n");
+         fprintf (asmFile, "%s", iComments2);
+         fprintf (asmFile, "\t.area BIT_BANK\t(REL,OVR,DATA)\n");
+         fprintf (asmFile, "bits:\n\t.ds 1\n");
+         fprintf (asmFile, "\tb0 = bits[0]\n");
+         fprintf (asmFile, "\tb1 = bits[1]\n");
+         fprintf (asmFile, "\tb2 = bits[2]\n");
+         fprintf (asmFile, "\tb3 = bits[3]\n");
+         fprintf (asmFile, "\tb4 = bits[4]\n");
+         fprintf (asmFile, "\tb5 = bits[5]\n");
+         fprintf (asmFile, "\tb6 = bits[6]\n");
+         fprintf (asmFile, "\tb7 = bits[7]\n");
       }
     }
 
@@ -1813,6 +1832,7 @@ glue (void)
    * the post_static_name area will immediately follow the static_name
    * area.
    */
+  tfprintf (asmFile, "\t!area\n", port->mem.home_name);
   tfprintf (asmFile, "\t!area\n", port->mem.static_name);       /* MOF */
   tfprintf (asmFile, "\t!area\n", port->mem.post_static_name);
   tfprintf (asmFile, "\t!area\n", port->mem.static_name);
@@ -1880,15 +1900,10 @@ glue (void)
   tfprintf (asmFile, "\t!areahome\n", HOME_NAME);
   copyFile (asmFile, home->oFile);
 
-  /* copy over code */
-  fprintf (asmFile, "%s", iComments2);
-  fprintf (asmFile, "; code\n");
-  fprintf (asmFile, "%s", iComments2);
-  tfprintf (asmFile, "\t!areacode\n", CODE_NAME);
   if (mainf && IFFUNC_HASBODY(mainf->type))
     {
 
-      /* entry point @ start of CSEG */
+      /* entry point @ start of HOME */
       fprintf (asmFile, "__sdcc_program_startup:\n");
 
       /* put in jump or call to main */
@@ -1904,6 +1919,11 @@ glue (void)
           fprintf (asmFile, "\tsjmp .\n");
         }
     }
+  /* copy over code */
+  fprintf (asmFile, "%s", iComments2);
+  fprintf (asmFile, "; code\n");
+  fprintf (asmFile, "%s", iComments2);
+  tfprintf (asmFile, "\t!areacode\n", options.code_seg);
   copyFile (asmFile, code->oFile);
 
   if (port->genAssemblerEnd) {