From 2745002e3c90e900346eef85749b7af622c06cd8 Mon Sep 17 00:00:00 2001 From: MaartenBrock Date: Sat, 30 Sep 2006 00:37:38 +0000 Subject: [PATCH] * 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 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4391 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 19 +++++++++++++++++++ src/SDCCglue.c | 10 ++++++++-- src/SDCCmem.c | 19 ++++++++++++++++++- src/SDCCmem.h | 2 ++ src/ds390/gen.c | 3 ++- src/ds390/main.c | 7 +++++-- src/hc08/main.c | 1 + src/mcs51/main.c | 1 + src/pic/main.c | 1 + src/pic16/main.c | 1 + src/port.h | 9 +++++---- src/xa51/main.c | 1 + src/z80/main.c | 2 ++ support/regression/fwk/include/testfwk.h | 1 + support/regression/tests/absolute.c | 24 ++++++++++++++++++++++++ 15 files changed, 91 insertions(+), 10 deletions(-) create mode 100644 support/regression/tests/absolute.c diff --git a/ChangeLog b/ChangeLog index 3368fca2..4f910616 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2006-09-30 Maarten Brock + + * 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 * src/mcs51/gen.c (genPlusIncr, genMinusDec, genAddrOf): small diff --git a/src/SDCCglue.c b/src/SDCCglue.c index be6d80e7..7cee8eb5 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -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--; } diff --git a/src/SDCCmem.c b/src/SDCCmem.c index ed4c4204..3be821ae 100644 --- a/src/SDCCmem.c +++ b/src/SDCCmem.c @@ -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? diff --git a/src/SDCCmem.h b/src/SDCCmem.h index 301fa339..a10d9e9b 100644 --- a/src/SDCCmem.h +++ b/src/SDCCmem.h @@ -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 */ diff --git a/src/ds390/gen.c b/src/ds390/gen.c index 5e0e63d8..b4354917 100644 --- a/src/ds390/gen.c +++ b/src/ds390/gen.c @@ -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)) { diff --git a/src/ds390/main.c b/src/ds390/main.c index d05c2ad0..dad9b748 100644 --- a/src/ds390/main.c +++ b/src/ds390/main.c @@ -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 diff --git a/src/hc08/main.c b/src/hc08/main.c index be780ab4..b4f62c89 100644 --- a/src/hc08/main.c +++ b/src/hc08/main.c @@ -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 diff --git a/src/mcs51/main.c b/src/mcs51/main.c index 71277b9a..6f122abc 100644 --- a/src/mcs51/main.c +++ b/src/mcs51/main.c @@ -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 diff --git a/src/pic/main.c b/src/pic/main.c index 263d5f81..dba9b231 100644 --- a/src/pic/main.c +++ b/src/pic/main.c @@ -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 diff --git a/src/pic16/main.c b/src/pic16/main.c index 7f77737c..7c9bb831 100644 --- a/src/pic16/main.c +++ b/src/pic16/main.c @@ -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 diff --git a/src/port.h b/src/port.h index 350e9b29..c980c607 100644 --- a/src/port.h +++ b/src/port.h @@ -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; diff --git a/src/xa51/main.c b/src/xa51/main.c index fee63186..d7353dee 100755 --- a/src/xa51/main.c +++ b/src/xa51/main.c @@ -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 diff --git a/src/z80/main.c b/src/z80/main.c index 7e589c07..89aba2a9 100644 --- a/src/z80/main.c +++ b/src/z80/main.c @@ -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 diff --git a/support/regression/fwk/include/testfwk.h b/support/regression/fwk/include/testfwk.h index bfe3d34e..29987ba9 100644 --- a/support/regression/fwk/include/testfwk.h +++ b/support/regression/fwk/include/testfwk.h @@ -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 index 00000000..52cc86ab --- /dev/null +++ b/support/regression/tests/absolute.c @@ -0,0 +1,24 @@ +/** Absolute addressing tests. + + mem: code +*/ +#include + +{mem} at(0xCAB7) char x = 'x'; +{mem} at(0xCAB9) char y = 'y'; +{mem} at(0xCAB0) int k = 0x1234; + +char z = 'z'; + +void +testAbsolute(void) +{ +#if defined(SDCC_mcs51) || defined(SDCC_ds390) || defined(SDCC_hc08) + char {mem} *pC = (char {mem} *)(0xCAB0); + int {mem} *pI = (char {mem} *)(0xCAB0); + + ASSERT(pC[7] == 'x'); + ASSERT(pC[9] == 'y'); + ASSERT(pI[0] == 0x1234); +#endif +} -- 2.47.2