* src/SDCCglue.c (emitMaps, glue),
authorMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 4 Mar 2007 21:04:39 +0000 (21:04 +0000)
committerMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 4 Mar 2007 21:04:39 +0000 (21:04 +0000)
* src/SDCCmem.c (initMem, allocDefault): added x_abs for initialized
  absolute xdata
* support/regression/tests/absolute.c: added xdata test

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4663 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/SDCCglue.c
src/SDCCmem.c
support/regression/tests/absolute.c

index 3c2d18d9ddd084f00941452da1c294707422ee70..0f510d9c282106d8472aac325de6b4b66bb504bc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-03-04 Maarten Brock <sourceforge.brock AT dse.nl>
+
+       * src/SDCCglue.c (emitMaps, glue),
+       * src/SDCCmem.c (initMem, allocDefault): added x_abs for initialized
+         absolute xdata
+       * support/regression/tests/absolute.c: added xdata test
+
 2007-03-03 Maarten Brock <sourceforge.brock AT dse.nl>
 
        * src/SDCCmain.c (parseCmdLine): only set options.xstack_loc for mcs51,
index fabe997584aa4f804d71c4fbe1cfce393341c48b..7e7d3008dfd4026f95a9e65c4e8b3ab59c8d6e57 100644 (file)
@@ -935,7 +935,7 @@ printIvalCharPtr (symbol * sym, sym_link * type, value * val, struct dbuf_s * oB
 
   /* PENDING: this is _very_ mcs51 specific, including a magic
      number...
-     It's also endin specific.
+     It's also endian specific.
    */
   size = getSize (type);
 
@@ -1322,6 +1322,7 @@ emitMaps (void)
   emitRegularMap (bit, TRUE, TRUE);
   emitRegularMap (pdata, TRUE, TRUE);
   emitRegularMap (xdata, TRUE, TRUE);
+  emitRegularMap (x_abs, TRUE, TRUE);
   if (port->genXINIT) {
     emitRegularMap (xidata, TRUE, TRUE);
   }
@@ -1589,13 +1590,13 @@ glue (void)
 
   if(port->general.glue_up_main &&
     (TARGET_IS_MCS51 || TARGET_IS_DS390 || TARGET_IS_XA51 || TARGET_IS_DS400))
-  {
+    {
       mcs51_like=1; /*So it has bits, sfr, sbits, data, idata, etc...*/
-  }
+    }
   else
-  {
+    {
       mcs51_like=0;
-  }
+    }
 
   /* print the global struct definitions */
   if (options.debug)
@@ -1642,11 +1643,11 @@ glue (void)
   tfprintf (asmFile, "\t!module\n",
     spacesToUnderscores (moduleBuf, moduleName, sizeof moduleBuf));
   if(mcs51_like)
-  {
-    fprintf (asmFile, "\t.optsdcc -m%s", port->target);
-
-    switch(options.model)
     {
+      fprintf (asmFile, "\t.optsdcc -m%s", port->target);
+
+      switch(options.model)
+      {
         case MODEL_SMALL:   fprintf (asmFile, " --model-small");   break;
         case MODEL_COMPACT: fprintf (asmFile, " --model-compact"); break;
         case MODEL_MEDIUM:  fprintf (asmFile, " --model-medium");  break;
@@ -1654,19 +1655,19 @@ glue (void)
         case MODEL_FLAT24:  fprintf (asmFile, " --model-flat24");  break;
         case MODEL_PAGE0:   fprintf (asmFile, " --model-page0");   break;
         default: break;
+      }
+      /*if(options.stackAuto)      fprintf (asmFile, " --stack-auto");*/
+      if(options.useXstack)      fprintf (asmFile, " --xstack");
+      /*if(options.intlong_rent)   fprintf (asmFile, " --int-long-rent");*/
+      /*if(options.float_rent)     fprintf (asmFile, " --float-rent");*/
+      if(options.noRegParams)    fprintf (asmFile, " --no-reg-params");
+      if(options.parms_in_bank1) fprintf (asmFile, " --parms-in-bank1");
+      fprintf (asmFile, "\n");
+    }
+  else if(TARGET_Z80_LIKE || TARGET_IS_HC08)
+    {
+      fprintf (asmFile, "\t.optsdcc -m%s\n", port->target);
     }
-    /*if(options.stackAuto)      fprintf (asmFile, " --stack-auto");*/
-    if(options.useXstack)      fprintf (asmFile, " --xstack");
-    /*if(options.intlong_rent)   fprintf (asmFile, " --int-long-rent");*/
-    /*if(options.float_rent)     fprintf (asmFile, " --float-rent");*/
-    if(options.noRegParams)    fprintf (asmFile, " --no-reg-params");
-    if(options.parms_in_bank1) fprintf (asmFile, " --parms-in-bank1");
-    fprintf (asmFile, "\n");
-  }
-  else if(TARGET_IS_Z80 || TARGET_IS_GBZ80 || TARGET_IS_HC08)
-  {
-    fprintf (asmFile, "\t.optsdcc -m%s\n", port->target);
-  }
 
   tfprintf (asmFile, "\t!fileprelude\n");
 
@@ -1682,14 +1683,14 @@ glue (void)
     printExterns (asmFile);
 
   if(( mcs51_like )
-   ||( TARGET_IS_Z80 )) /*.p.t.20030924 need to output SFR table for Z80 as well */
-  {
+     ||( TARGET_IS_Z80 )) /*.p.t.20030924 need to output SFR table for Z80 as well */
+    {
       /* copy the sfr segment */
       fprintf (asmFile, "%s", iComments2);
       fprintf (asmFile, "; special function registers\n");
       fprintf (asmFile, "%s", iComments2);
       dbuf_write_and_destroy (&sfr->oBuf, asmFile);
-  }
+    }
   
   if(mcs51_like)
     {
@@ -1701,35 +1702,35 @@ glue (void)
 
       /*JCF: Create the areas for the register banks*/
       if(RegBankUsed[0]||RegBankUsed[1]||RegBankUsed[2]||RegBankUsed[3])
-      {
-         fprintf (asmFile, "%s", iComments2);
-         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");
-         if(RegBankUsed[1]||options.parms_in_bank1)
-           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");
-         if(RegBankUsed[3])
-           fprintf (asmFile, "\t.area REG_BANK_3\t(REL,OVR,DATA)\n\t.ds 8\n");
-      }
+        {
+          fprintf (asmFile, "%s", iComments2);
+          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");
+          if(RegBankUsed[1]||options.parms_in_bank1)
+            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");
+          if(RegBankUsed[3])
+            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");
-      }
+        {
+          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");
+        }
     }
 
   /* copy the data segment */
@@ -1740,12 +1741,13 @@ glue (void)
 
 
   /* create the overlay segments */
-  if (overlay) {
-    fprintf (asmFile, "%s", iComments2);
-    fprintf (asmFile, "; overlayable items in %s ram \n", mcs51_like?"internal":"");
-    fprintf (asmFile, "%s", iComments2);
-    dbuf_write_and_destroy (&ovrBuf, asmFile);
-  }
+  if (overlay)
+    {
+      fprintf (asmFile, "%s", iComments2);
+      fprintf (asmFile, "; overlayable items in %s ram \n", mcs51_like?"internal":"");
+      fprintf (asmFile, "%s", iComments2);
+      dbuf_write_and_destroy (&ovrBuf, asmFile);
+    }
 
   /* create the stack segment MOF */
   if (mainf && IFFUNC_HASBODY(mainf->type))
@@ -1758,29 +1760,32 @@ glue (void)
     }
 
   /* create the idata segment */
-  if ( (idata) && (mcs51_like) ) {
-    fprintf (asmFile, "%s", iComments2);
-    fprintf (asmFile, "; indirectly addressable internal ram data\n");
-    fprintf (asmFile, "%s", iComments2);
-    dbuf_write_and_destroy (&idata->oBuf, asmFile);
-  }
+  if ( (idata) && (mcs51_like) )
+    {
+      fprintf (asmFile, "%s", iComments2);
+      fprintf (asmFile, "; indirectly addressable internal ram data\n");
+      fprintf (asmFile, "%s", iComments2);
+      dbuf_write_and_destroy (&idata->oBuf, asmFile);
+    }
 
   /* create the absolute idata/data segment */
-  if ( (i_abs) && (mcs51_like) ) {
-    fprintf (asmFile, "%s", iComments2);
-    fprintf (asmFile, "; absolute internal ram data\n");
-    fprintf (asmFile, "%s", iComments2);
-    dbuf_write_and_destroy (&d_abs->oBuf, asmFile);
-    dbuf_write_and_destroy (&i_abs->oBuf, asmFile);
-  }
+  if ( (i_abs) && (mcs51_like) )
+    {
+      fprintf (asmFile, "%s", iComments2);
+      fprintf (asmFile, "; absolute internal ram data\n");
+      fprintf (asmFile, "%s", iComments2);
+      dbuf_write_and_destroy (&d_abs->oBuf, asmFile);
+      dbuf_write_and_destroy (&i_abs->oBuf, asmFile);
+    }
 
   /* copy the bit segment */
-  if (mcs51_like) {
-    fprintf (asmFile, "%s", iComments2);
-    fprintf (asmFile, "; bit data\n");
-    fprintf (asmFile, "%s", iComments2);
-    dbuf_write_and_destroy (&bit->oBuf, asmFile);
-  }
+  if (mcs51_like)
+    {
+      fprintf (asmFile, "%s", iComments2);
+      fprintf (asmFile, "; bit data\n");
+      fprintf (asmFile, "%s", iComments2);
+      dbuf_write_and_destroy (&bit->oBuf, asmFile);
+    }
 
   /* copy paged external ram data */
   if (mcs51_like)
@@ -1802,12 +1807,22 @@ glue (void)
     }
 
   /* copy external ram data */
-  if (mcs51_like) {
-    fprintf (asmFile, "%s", iComments2);
-    fprintf (asmFile, "; external ram data\n");
-    fprintf (asmFile, "%s", iComments2);
-    dbuf_write_and_destroy (&xdata->oBuf, asmFile);
-  }
+  if (mcs51_like)
+    {
+      fprintf (asmFile, "%s", iComments2);
+      fprintf (asmFile, "; external ram data\n");
+      fprintf (asmFile, "%s", iComments2);
+      dbuf_write_and_destroy (&xdata->oBuf, asmFile);
+    }
+
+  /* create the absolute xdata segment */
+  if (mcs51_like || TARGET_IS_HC08)
+    {
+      fprintf (asmFile, "%s", iComments2);
+      fprintf (asmFile, "; absolute external ram data\n");
+      fprintf (asmFile, "%s", iComments2);
+      dbuf_write_and_destroy (&x_abs->oBuf, asmFile);
+    }
 
   /* copy external initialized ram data */
   fprintf (asmFile, "%s", iComments2);
@@ -1817,10 +1832,10 @@ glue (void)
 
   /* If the port wants to generate any extra areas, let it do so. */
   if (port->extraAreas.genExtraAreaDeclaration)
-  {
+    {
       port->extraAreas.genExtraAreaDeclaration(asmFile, 
                                                mainf && IFFUNC_HASBODY(mainf->type));
-  }
+    }
     
   /* copy the interrupt vector table */
   if (mainf && IFFUNC_HASBODY(mainf->type))
@@ -1855,6 +1870,7 @@ glue (void)
         }
       else
         {
+          assert (mcs51_like);
           fprintf (asmFile, "__sdcc_gsinit_startup:\n");
           /* if external stack is specified then the
              higher order byte of the xdatalocation is
@@ -1889,7 +1905,6 @@ glue (void)
               port->genXINIT(asmFile);
             }
         }
-
     }
   dbuf_write_and_destroy (&statsg->oBuf, asmFile);
 
@@ -1935,8 +1950,9 @@ glue (void)
   tfprintf (asmFile, "\t!areacode\n", options.code_seg);
   dbuf_write_and_destroy (&code->oBuf, asmFile);
 
-  if (port->genAssemblerEnd) {
+  if (port->genAssemblerEnd)
+    {
       port->genAssemblerEnd(asmFile);
-  }
+    }
   fclose (asmFile);
 }
index a128b8b674991f130e2b4eeb2191ce88b35a80a2..351e59c9fecf6defe350a8e5ee9d1949ef1749f7 100644 (file)
@@ -107,12 +107,14 @@ initMem ()
      DEBUG-NAME     -   'B'
      POINTER-TYPE   -   POINTER
    */
-  if (ISTACK_NAME) {
-    istack = allocMap (0, 0, 0, 0, 0, 0, options.stack_loc,
-                       ISTACK_NAME, 'B', POINTER);
-  } else {
-    istack=NULL;
-  }
+  if (ISTACK_NAME)
+    {
+      istack = allocMap (0, 0, 0, 0, 0, 0, options.stack_loc, ISTACK_NAME, 'B', POINTER);
+    }
+  else
+    {
+      istack = NULL;
+    }
 
   /* code  segment ;
      SFRSPACE       -   NO
@@ -184,11 +186,14 @@ initMem ()
      DEBUG-NAME     -   'E'
      POINTER-TYPE   -   POINTER
    */
-  if (IABS_NAME) {
-    d_abs = allocMap (0, 0, 0, 1, 0, 0, options.data_loc, IABS_NAME, 'E', POINTER);
-  } else {
-    d_abs = NULL;
-  }
+  if (IABS_NAME)
+    {
+      d_abs = allocMap (0, 0, 0, 1, 0, 0, options.data_loc, IABS_NAME, 'E', POINTER);
+    }
+  else
+    {
+      d_abs = NULL;
+    }
 
   /* overlay segment - same as internal storage segment ;
      SFRSPACE       -   NO
@@ -200,11 +205,14 @@ initMem ()
      DEBUG-NAME     -   'E'
      POINTER-TYPE   -   POINTER
    */
-  if (OVERLAY_NAME) {
-    overlay = allocMap (0, 0, 0, 1, 0, 0, options.data_loc, DATA_NAME, 'E', POINTER);
-  } else {
-    overlay = NULL;
-  }
+  if (OVERLAY_NAME)
+    {
+      overlay = allocMap (0, 0, 0, 1, 0, 0, options.data_loc, DATA_NAME, 'E', POINTER);
+    }
+  else
+    {
+      overlay = NULL;
+    }
 
   /* Xternal paged segment ;   
      SFRSPACE       -   NO
@@ -216,11 +224,14 @@ initMem ()
      DEBUG-NAME     -   'P'
      POINTER-TYPE   -   PPOINTER
    */
-  if (PDATA_NAME) {
-    pdata = allocMap (0, 0, 1, 0, 0, 0, options.xstack_loc, PDATA_NAME, 'P', PPOINTER);
-  } else {
-    pdata = NULL;
-  }
+  if (PDATA_NAME)
+    {
+      pdata = allocMap (0, 0, 1, 0, 0, 0, options.xstack_loc, PDATA_NAME, 'P', PPOINTER);
+    }
+  else
+    {
+      pdata = NULL;
+    }
 
   /* Xternal Data segment -
      SFRSPACE       -   NO
@@ -236,6 +247,25 @@ initMem ()
   xidata = allocMap (0, 1, 0, 0, 0, 0, 0, XIDATA_NAME, 'F', FPOINTER);
   xinit = allocMap (0, 1, 0, 0, 0, 1, 0, XINIT_NAME, 'C', CPOINTER);
 
+  /* Absolute external storage segment ;
+     SFRSPACE       -   NO
+     FAR-SPACE      -   YES
+     PAGED          -   NO
+     DIRECT-ACCESS  -   NO
+     BIT-ACCESS     -   NO
+     CODE-ACCESS    -   NO
+     DEBUG-NAME     -   'F'
+     POINTER-TYPE   -   FPOINTER
+   */
+  if (XABS_NAME)
+    {
+      x_abs = allocMap (0, 1, 0, 0, 0, 0, options.xdata_loc, XABS_NAME, 'F', FPOINTER);
+    }
+  else
+    {
+      x_abs = NULL;
+    }
+
   /* Indirectly addressed internal data segment
      SFRSPACE       -   NO
      FAR-SPACE      -   NO
@@ -246,12 +276,14 @@ initMem ()
      DEBUG-NAME     -   'G'
      POINTER-TYPE   -   IPOINTER
    */
-  if (IDATA_NAME) {
-    idata = allocMap (0, 0, 0, 0, 0, 0, options.idata_loc,
-                      IDATA_NAME, 'G', IPOINTER);
-  } else {
-    idata=NULL;
-  }
+  if (IDATA_NAME)
+    {
+      idata = allocMap (0, 0, 0, 0, 0, 0, options.idata_loc, IDATA_NAME, 'G', IPOINTER);
+    }
+  else
+    {
+      idata = NULL;
+    }
 
   /* Indirectly addressed absolute internal segment
      SFRSPACE       -   NO
@@ -263,11 +295,14 @@ initMem ()
      DEBUG-NAME     -   'E'
      POINTER-TYPE   -   IPOINTER
    */
-  if (IABS_NAME) {
-    i_abs = allocMap (0, 0, 0, 0, 0, 0, options.data_loc, IABS_NAME, 'E', IPOINTER);
-  } else {
-    i_abs = NULL;
-  }
+  if (IABS_NAME)
+    {
+      i_abs = allocMap (0, 0, 0, 0, 0, 0, options.data_loc, IABS_NAME, 'E', IPOINTER);
+    }
+  else
+    {
+      i_abs = NULL;
+    }
 
   /* Bit space ;
      SFRSPACE       -   NO
@@ -376,36 +411,52 @@ allocDefault (symbol * sym)
       if (sym->_isparm)
         return FALSE;
       /* if code change to constant */
-      if (sym->ival && (sym->level==0) && SPEC_ABSA (sym->etype)) {
-        SPEC_OCLS(sym->etype) = c_abs;
-      } else {
-        SPEC_OCLS (sym->etype) = statsg;
-      }
+      if (sym->ival && (sym->level==0) && SPEC_ABSA (sym->etype))
+        {
+          SPEC_OCLS(sym->etype) = c_abs;
+        }
+      else
+        {
+          SPEC_OCLS (sym->etype) = statsg;
+        }
       break;
     case S_XDATA:
-      // should we move this to the initialized data segment?
-      if (port->genXINIT &&
-          sym->ival && (sym->level==0) && !SPEC_ABSA (sym->etype)) {
-        SPEC_OCLS(sym->etype) = xidata;
-      } else {
-        SPEC_OCLS (sym->etype) = xdata;
-      }
+      /* absolute initialized global */
+      if (sym->ival && (sym->level==0) && SPEC_ABSA (sym->etype))
+        {
+          SPEC_OCLS(sym->etype) = x_abs;
+        }
+      /* or should we move this to the initialized data segment? */
+      else if (port->genXINIT && sym->ival && (sym->level==0))
+        {
+          SPEC_OCLS(sym->etype) = xidata;
+        }
+      else
+        {
+          SPEC_OCLS (sym->etype) = xdata;
+        }
       break;
     case S_DATA:
       /* absolute initialized global */
-      if (sym->ival && (sym->level==0) && SPEC_ABSA (sym->etype)) {
-        SPEC_OCLS(sym->etype) = d_abs;
-      } else {
-        SPEC_OCLS (sym->etype) = data;
-      }
+      if (sym->ival && (sym->level==0) && SPEC_ABSA (sym->etype))
+        {
+          SPEC_OCLS(sym->etype) = d_abs;
+        }
+      else
+        {
+          SPEC_OCLS (sym->etype) = data;
+        }
       break;
     case S_IDATA:
       /* absolute initialized global */
-      if (sym->ival && (sym->level==0) && SPEC_ABSA (sym->etype)) {
-        SPEC_OCLS(sym->etype) = i_abs;
-      } else {
-        SPEC_OCLS (sym->etype) = idata;
-      }
+      if (sym->ival && (sym->level==0) && SPEC_ABSA (sym->etype))
+        {
+          SPEC_OCLS(sym->etype) = i_abs;
+        }
+      else
+        {
+          SPEC_OCLS (sym->etype) = idata;
+        }
       sym->iaccess = 1;
       break;
     case S_PDATA:
index 528ea543a519b5e0a05d8493f3b1e5fb345b35a2..613c84bc582d0d2dedced268b36f0cfd38d1cec3 100644 (file)
@@ -1,6 +1,6 @@
 /** Absolute addressing tests.\r
 \r
-    mem: code\r
+    mem: code, xdata\r
 */\r
 #include <testfwk.h>\r
 \r
@@ -16,7 +16,7 @@ testAbsolute(void)
 {\r
 #if defined(SDCC_mcs51) || defined(SDCC_ds390) || defined(SDCC_hc08)\r
   char {mem} *pC = (char {mem} *)(0xCAB0);\r
-  int  {mem} *pI = (char {mem} *)(0xCAB0);\r
+  int  {mem} *pI = (int  {mem} *)(0xCAB0);\r
 \r
   ASSERT(u == 'x');\r
   ASSERT(pC[7] == 'x');\r