+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
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));
/* 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);
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--;
}
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 */
*/
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
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?
#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 */
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 */
_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)) {
"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
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
"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
"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
"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
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
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
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 */
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;
"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
NULL, /* xidata */
NULL, /* xinit */
NULL, /* const_name */
+ "CABS", /* cabs_name */
NULL,
NULL,
1
NULL, /* xidata */
NULL, /* xinit */
NULL, /* const_name */
+ "CABS", /* cabs_name */
NULL,
NULL,
1
# define pdata
# define xdata
# define code
+# define at(x)
#endif
#if defined(SDCC_hc08)
--- /dev/null
+/** 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