]> git.gag.com Git - fw/sdcc/commitdiff
* src/port.h: added mem.cabs_name to PORT
authorMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 30 Sep 2006 00:37:38 +0000 (00:37 +0000)
committerMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 30 Sep 2006 00:37:38 +0000 (00:37 +0000)
* src/ds390/main.c,
* src/hc08/main.c,
* src/mcs51/main.c,
* src/pic16/main.c,
* src/pic/main.c,
* src/xa51/main.c,
* src/z80/main.c: added cabs_name initializers
* src/SDCCglue.c (emitStaticSeg): allocate and initialize absolute
  constants
  (emitMaps): emit absolutes in code memory into cabs_name
* src/SDCCmem.c,
* src/SDCCmem.h: added memory map c_abs and defined CABS_NAME
* src/ds390/gen.c (genCodePointerGet): fixed bug if left is a literal
* support/regression/fwk/include/testfwk.h: added define for at
* support/regression/tests/absolute.c: added, new

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

15 files changed:
ChangeLog
src/SDCCglue.c
src/SDCCmem.c
src/SDCCmem.h
src/ds390/gen.c
src/ds390/main.c
src/hc08/main.c
src/mcs51/main.c
src/pic/main.c
src/pic16/main.c
src/port.h
src/xa51/main.c
src/z80/main.c
support/regression/fwk/include/testfwk.h
support/regression/tests/absolute.c [new file with mode: 0644]

index 3368fca2df38c259f048c2a056a8cc7ed9e62486..4f9106166148fbdae0916aa7568c01a5c58a366b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2006-09-30 Maarten Brock <sourceforge.brock AT dse.nl>
+
+       * src/port.h: added mem.cabs_name to PORT
+       * src/ds390/main.c,
+       * src/hc08/main.c,
+       * src/mcs51/main.c,
+       * src/pic16/main.c,
+       * src/pic/main.c,
+       * src/xa51/main.c,
+       * src/z80/main.c: added cabs_name initializers
+       * src/SDCCglue.c (emitStaticSeg): allocate and initialize absolute
+         constants
+         (emitMaps): emit absolutes in code memory into cabs_name
+       * src/SDCCmem.c,
+       * src/SDCCmem.h: added memory map c_abs and defined CABS_NAME
+       * src/ds390/gen.c (genCodePointerGet): fixed bug if left is a literal
+       * support/regression/fwk/include/testfwk.h: added define for at
+       * support/regression/tests/absolute.c: added, new
+
 2006-09-29 Maarten Brock <sourceforge.brock AT dse.nl>
 
        * src/mcs51/gen.c (genPlusIncr, genMinusDec, genAddrOf): small
index be6d80e76d1bda3ecf1403788b99c12efdc5e01d..7cee8eb5841661ff1dda373b7a51ce60c5369f76 100644 (file)
@@ -1276,8 +1276,8 @@ emitStaticSeg (memmap * map, FILE * out)
         fprintf (out, "%s$%d$%d", sym->name, sym->level, sym->block);
       }
       
-      /* if it has an absolute address */
-      if (SPEC_ABSA (sym->etype))
+      /* if it has an absolute address and no initializer */
+      if (SPEC_ABSA (sym->etype) && !sym->ival)
         {
           if (options.debug)
             fprintf (out, " == 0x%04x\n", SPEC_ADDR (sym->etype));
@@ -1294,6 +1294,10 @@ emitStaticSeg (memmap * map, FILE * out)
           /* if it has an initial value */
           if (sym->ival)
             {
+              if (SPEC_ABSA (sym->etype))
+                {
+                  tfprintf (out, "\t!org\n", SPEC_ADDR (sym->etype));
+                }
               fprintf (out, "%s:\n", sym->rname);
               noAlloc++;
               resolveIvalSym (sym->ival, sym->type);
@@ -1361,6 +1365,8 @@ emitMaps (void)
     tfprintf (code->oFile, "\t!area\n", xinit->sname);
     emitStaticSeg (xinit, code->oFile);
   }
+  tfprintf (code->oFile, "\t!area\n", c_abs->sname);
+  emitStaticSeg (c_abs, code->oFile);
   inInitMode--;
 }
 
index ed4c4204022e0e0a80d23b16f72914202f87b4c7..3be821aecc8012fe238d1ea340260d2e6f5f9c65 100644 (file)
@@ -16,6 +16,7 @@ memmap *xinit = NULL;           /* the initializers for xidata */
 memmap *idata = NULL;           /* internal data upto 256      */
 memmap *bit = NULL;             /* bit addressable space       */
 memmap *statsg = NULL;          /* the constant data segment   */
+memmap *c_abs = NULL;           /* constant absolute data      */
 memmap *sfr = NULL;             /* register space              */
 memmap *reg = NULL;             /* register space              */
 memmap *sfrbit = NULL;          /* sfr bit space               */
@@ -148,6 +149,18 @@ initMem ()
    */
   statsg = allocMap (0, 1, 0, 0, 0, 1, 0, STATIC_NAME, 'D', CPOINTER);
 
+  /* Constant Absolute Data segment (for variables );
+     SFRSPACE       -   NO
+     FAR-SPACE      -   YES
+     PAGED          -   NO
+     DIRECT-ACCESS  -   NO
+     BIT-ACCESS     -   NO
+     CODE-ACCESS    -   YES
+     DEBUG-NAME     -   'D'
+     POINTER-TYPE   -   CPOINTER
+   */
+  c_abs = allocMap (0, 1, 0, 0, 0, 1, 0, CABS_NAME, 'D', CPOINTER);
+
   /* Data segment - internal storage segment ;
      SFRSPACE       -   NO
      FAR-SPACE      -   NO
@@ -330,7 +343,11 @@ allocDefault (symbol * sym)
       if (sym->_isparm)
         return FALSE;
       /* if code change to constant */
-      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?
index 301fa33919df0e478c32294eed64ca751760f265..a10d9e9bbffaae692e772a42e6ba0fde8fafa6dd 100644 (file)
@@ -46,6 +46,7 @@ extern FILE *junkFile;
 #define         HOME_NAME     port->mem.home_name
 #define  OVERLAY_NAME  port->mem.overlay_name
 #define  CONST_NAME    port->mem.const_name
+#define  CABS_NAME     port->mem.cabs_name
 
 /* forward definition for variables */
 extern memmap *xstack;         /* xternal stack data           */
@@ -59,6 +60,7 @@ extern memmap *xinit;           /* the initializers for xidata  */
 extern memmap *idata;          /* internal data upto 256       */
 extern memmap *bit;            /* bit addressable space        */
 extern memmap *statsg;         /* static code segment          */
+extern memmap *c_abs;          /* constant absolute data       */
 extern memmap *sfr;            /* register space               */
 extern memmap *sfrbit;         /* sfr bit space                */
 extern memmap *reg;            /* register space               */
index 5e0e63d824ed7f5d42110ed183d8444fb035be09..b43549176e1b3040f3397fbdbd4a02007384c227 100644 (file)
@@ -10904,7 +10904,8 @@ genCodePointerGet (operand * left,
           _endLazyDPSEvaluation ();
       }
       pi->generated = 1;
-  } else if ((OP_SYMBOL(left)->ruonly || AOP_INDPTRn(left)) &&
+  } else if (IS_SYMOP(left) &&
+             (OP_SYMBOL(left)->ruonly || AOP_INDPTRn(left)) &&
              AOP_SIZE(result) > 1 &&
              (OP_SYMBOL (left)->liveTo > ic->seq || ic->depth)) {
 
index d05c2ad08a9a94ec6fec91ee6ba9fbf2c824ed66..dad9b7488824e013267a6e0fe56f8f2e80ac6313 100644 (file)
@@ -879,9 +879,10 @@ PORT ds390_port =
     "OSEG    (OVR,DATA)",
     "GSFINAL (CODE)",
     "HOME    (CODE)",
-    "XISEG   (XDATA)", // initialized xdata
-    "XINIT   (CODE)", // a code copy of xiseg
+    "XISEG   (XDATA)",         // initialized xdata
+    "XINIT   (CODE)",          // a code copy of xiseg
     "CONST   (CODE)",          // const_name - const data (code or not)
+    "CABS    (ABS,CODE)",      // cabs_name - const absolute data (code or not)
     NULL,
     NULL,
     1
@@ -1198,6 +1199,7 @@ PORT tininative_port =
     NULL,
     NULL,
     "CONST   (CODE)",          // const_name - const data (code or not)
+    "CABS    (ABS,CODE)",      // cabs_name - const absolute data (code or not)
     NULL,
     NULL,
     1
@@ -1430,6 +1432,7 @@ PORT ds400_port =
     "XISEG   (XDATA)", // initialized xdata
     "XINIT   (CODE)", // a code copy of xiseg
     "CONST   (CODE)",          // const_name - const data (code or not)
+    "CABS    (ABS,CODE)",      // cabs_name - const absolute data (code or not)
     NULL,
     NULL,
     1
index be780ab42b182f99dd7a5fd9c381732b6b6f9f39..b4f62c89c252ffc4501c1ecbccd5d49e05a84930 100644 (file)
@@ -439,6 +439,7 @@ PORT hc08_port =
     "XISEG", // initialized xdata
     "XINIT", // a code copy of xiseg
     "CONST   (CODE)", // const_name - const data (code or not)
+    "CABS    (ABS,CODE)", // cabs_name - const absolute data (code or not)
     NULL,
     NULL,
     1
index 71277b9a25d5c8fcfacdeb9c24caaecd6b692f9e..6f122abc394f6b0093cd2e9458eac629bbcdc19b 100644 (file)
@@ -754,6 +754,7 @@ PORT mcs51_port =
     "XISEG   (XDATA)",          // xidata_name - initialized xdata   initialized xdata
     "XINIT   (CODE)",           // xinit_name - a code copy of xiseg
     "CONST   (CODE)",           // const_name - const data (code or not)
+    "CABS    (ABS,CODE)",       // cabs_name - const absolute data (code or not)
     NULL,
     NULL,
     1
index 263d5f81eda1f734b503b5732c9013273c2b2ed9..dba9b231623140d09fe0fbc320c8a207cf64bb21 100644 (file)
@@ -559,6 +559,7 @@ PORT pic_port =
                NULL, // xidata
                NULL, // xinit
                "CONST   (CODE)",               // const_name - const data (code or not)
+               "CABS    (ABS,CODE)",   // cabs_name - const absolute data (code or not)
                NULL,
                NULL,
                1        // code is read only
index 7f77737c87f7e0371b2bfeb4c468d9fe1dd20178..7c9bb8312dd3207da693b26b233d667e5fe984d6 100644 (file)
@@ -1191,6 +1191,7 @@ PORT pic16_port =
     NULL,                      // xidata
     NULL,                      // xinit
     "CONST   (CODE)",          // const_name - const data (code or not)
+    "CABS    (ABS,CODE)",      // cabs_name - const absolute data (code or not)
     NULL,                      // default location for auto vars
     NULL,                      // default location for global vars
     1                          // code is read only 1=yes
index 350e9b29894630ffc509aebd121059ed9396a6d3..c980c6075a10a6681c614585f453aaf0e46bd4ab 100644 (file)
@@ -167,6 +167,7 @@ typedef struct
        const char *xidata_name; // initialized xdata
        const char *xinit_name; // a code copy of xidata
        const char *const_name; // const data (code or not)
+       const char *cabs_name; // const absolute data (code or not)
        struct memmap *default_local_map; // default location for auto vars
        struct memmap *default_globl_map; // default location for globl vars
        int code_ro;            /* code space read-only 1=yes */
@@ -201,10 +202,10 @@ typedef struct
 
     struct
       {
-       /** One more than the smallest
-           mul/div operation the processor can do nativley
-           Eg if the processor has an 8 bit mul, nativebelow is 2 */
-       unsigned muldiv;
+        /** One more than the smallest
+            mul/div operation the processor can do natively
+            Eg if the processor has an 8 bit mul, native below is 2 */
+        unsigned muldiv;
         unsigned shift;
       }
     support;
index fee631866229a848724a3d8864a377f6ab2bf784..d7353dee9ae108f1c6b9460770fded58b6bd0853 100755 (executable)
@@ -288,6 +288,7 @@ PORT xa51_port =
     "XISEG   (XDATA)", // initialized xdata
     "XINIT   (CODE)", // a code copy of xiseg
     "CONST   (CODE)",          // const_name - const data (code or not)
+    "CABS    (ABS,CODE)",      // cabs_name - const absolute data (code or not)
     NULL, // default local map
     NULL, // default global map
     1
index 7e589c0790cbd80f7242a478672b2a9a8513684d..89aba2a9515e9df3e1fc3137620e2b058d9e55d0 100644 (file)
@@ -617,6 +617,7 @@ PORT z80_port =
     NULL, /* xidata */
     NULL, /* xinit */
     NULL, /* const_name */
+    "CABS", /* cabs_name */
     NULL,
     NULL,
     1
@@ -736,6 +737,7 @@ PORT gbz80_port =
     NULL, /* xidata */
     NULL, /* xinit */
     NULL, /* const_name */
+    "CABS", /* cabs_name */
     NULL,
     NULL,
     1
index bfe3d34e89a20fb11aac62575d03b8ee33ae814c..29987ba9940c1683ef10816d706d31f476becce8 100644 (file)
@@ -30,6 +30,7 @@ void __runSuite(void);
 # define pdata
 # define xdata
 # define code
+# define at(x)
 #endif
 
 #if defined(SDCC_hc08)
diff --git a/support/regression/tests/absolute.c b/support/regression/tests/absolute.c
new file mode 100644 (file)
index 0000000..52cc86a
--- /dev/null
@@ -0,0 +1,24 @@
+/** Absolute addressing tests.\r
+\r
+    mem: code\r
+*/\r
+#include <testfwk.h>\r
+\r
+{mem} at(0xCAB7) char x = 'x';\r
+{mem} at(0xCAB9) char y = 'y';\r
+{mem} at(0xCAB0) int  k = 0x1234;\r
+\r
+char z = 'z';\r
+\r
+void\r
+testAbsolute(void)\r
+{\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
+\r
+  ASSERT(pC[7] == 'x');\r
+  ASSERT(pC[9] == 'y');\r
+  ASSERT(pI[0] == 0x1234);\r
+#endif\r
+}\r