From: MaartenBrock Date: Thu, 21 Dec 2006 20:46:09 +0000 (+0000) Subject: * as/link/mcs51/lkarea.c (lnkarea2): handle absolute areas, restructured X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=d7b30120ae115e8929d57e25038ca76dde13974e;p=fw%2Fsdcc * as/link/mcs51/lkarea.c (lnkarea2): handle absolute areas, restructured BSEG handling, (lnksect2): use --data-loc and --idata-loc as lower bound for ramstart, corrected overlayed areax addresses, warn about memory overlaps * as/mcs51/asmain.c (asmbl): create a new area for every .org directive * src/avr/main.c, * 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, * src/port.h: added xabs_name and iabs_name * src/SDCCglue.c (emitRegularMap): allocate for absolutes with initializer (glue, emitMaps): create and emit maps d_abs and i_abs * src/SDCCglue.h: cosmetic changes * src/SDCCmain.c (setDefaultOptions): idata can start below 0x80 * src/SDCCmem.h, * src/SDCCmem.c (initMem): added x_abs, i_abs and d_abs (allocDefault): put absolute, initialized globals in them * support/regression/tests/absolute.c: added absolute bdata test * device/lib/printf_large.c (output_float): moved fpBuffer to stack/xdata git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4521 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index 45ae76dc..6649830a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,29 @@ +2006-12-21 Maarten Brock + + * as/link/mcs51/lkarea.c (lnkarea2): handle absolute areas, restructured + BSEG handling, + (lnksect2): use --data-loc and --idata-loc as lower bound for ramstart, + corrected overlayed areax addresses, warn about memory overlaps + * as/mcs51/asmain.c (asmbl): create a new area for every .org directive + * src/avr/main.c, + * 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, + * src/port.h: added xabs_name and iabs_name + * src/SDCCglue.c (emitRegularMap): allocate for absolutes with initializer + (glue, emitMaps): create and emit maps d_abs and i_abs + * src/SDCCglue.h: cosmetic changes + * src/SDCCmain.c (setDefaultOptions): idata can start below 0x80 + * src/SDCCmem.h, + * src/SDCCmem.c (initMem): added x_abs, i_abs and d_abs + (allocDefault): put absolute, initialized globals in them + * support/regression/tests/absolute.c: added absolute bdata test + * device/lib/printf_large.c (output_float): moved fpBuffer to stack/xdata + 2006-12-20 Borut Razem * support/cpp2/cpphash.h, support/cpp2/cpplex.c: fixed bug #982435 diff --git a/as/link/mcs51/lkarea.c b/as/link/mcs51/lkarea.c index a227b71f..e779836d 100644 --- a/as/link/mcs51/lkarea.c +++ b/as/link/mcs51/lkarea.c @@ -493,6 +493,8 @@ Addr_T lnksect2 (struct area *tap, int locIndex); char idatamap[256]; unsigned long codemap[524288]; unsigned long xdatamap[131072]; +struct area *dseg_ap = NULL; +struct area *iseg_ap = NULL; /*Modified version of the functions for packing variables in internal data memory*/ VOID lnkarea2 (void) @@ -503,7 +505,7 @@ VOID lnkarea2 (void) char temp[NCPS]; struct sym *sp; int j; - struct area *dseg_ap = NULL; + struct area *bseg_ap = NULL; struct area *abs_ap = NULL; struct area *gs0_ap = NULL; struct sym *sp_dseg_s=NULL, *sp_dseg_l=NULL; @@ -534,8 +536,13 @@ VOID lnkarea2 (void) /* next accumulate all GSINITx/GSFINAL area sizes into GSINIT so they stay together */ ap = areap; + abs_ap = areap; while (ap) { + if (ap->a_flag & A_ABS) + { + abs_ap = ap; /* Remember the last abs area */ + } if (!strncmp(ap->a_id, "GS", 2)) {/* GSxxxxx area */ if (ap->a_size == 0) @@ -553,6 +560,27 @@ VOID lnkarea2 (void) gs0_ap = ap; } } + /*Since area BSEG is defined just before BSEG_BYTES, use the bit size of BSEG + to compute the byte size of BSEG_BYTES: */ + else if (!strcmp(ap->a_id, "BSEG")) + { + bseg_ap = ap->a_ap; //BSEG_BYTES + for (axp=ap->a_axp; axp; axp=axp->a_axp) + ap->a_size += axp->a_size; + bseg_ap->a_axp->a_size = ((ap->a_addr + ap->a_size + 7)/8); /*Bits to bytes*/ + ap->a_ap = bseg_ap->a_ap; //removed BSEG_BYTES from list + bseg_ap->a_ap = abs_ap->a_ap; + abs_ap->a_ap = bseg_ap; //inserted BSEG_BYTES after abs + bseg_ap = ap; //BSEG + } + else if (!strcmp(ap->a_id, "DSEG")) + { + dseg_ap = ap; /*Need it later*/ + } + else if (!strcmp(ap->a_id, "ISEG")) + { + iseg_ap = ap; /*Need it later*/ + } ap = ap->a_ap; } if (gs0_ap) @@ -582,6 +610,10 @@ VOID lnkarea2 (void) rloc[locIndex] = lnksect2(ap, locIndex); } + if (!strcmp(ap->a_id, "BSEG_BYTES")) + { + bseg_ap->a_addr = (ap->a_axp->a_addr - 0x20) * 8; /*Bytes to bits*/ + } /* * Create symbols called: * s_ the start address of the area @@ -595,7 +627,7 @@ VOID lnkarea2 (void) *temp = 's'; sp = lkpsym(temp, 1); - sp->s_addr = ap->a_addr ; + sp->s_addr = ap->a_addr; sp->s_type |= S_DEF; if (!strcmp(ap->a_id, "DSEG")) sp_dseg_s=sp; @@ -607,16 +639,6 @@ VOID lnkarea2 (void) if (!strcmp(ap->a_id, "DSEG")) sp_dseg_l=sp; } - /*Since area BSEG is defined just before BSEG_BYTES, use the bit size of BSEG - to compute the byte size of BSEG_BYTES: */ - if (!strcmp(ap->a_id, "BSEG")) - { - ap->a_ap->a_axp->a_size = ((ap->a_addr + ap->a_size + 7)/8); /*Bits to bytes*/ - } - else if (!strcmp(ap->a_id, "DSEG")) - { - dseg_ap=ap; /*Need it later to set its correct size*/ - } ap = ap->a_ap; } @@ -714,7 +736,7 @@ Addr_T lnksect2 (struct area *tap, int locIndex) { register Addr_T size, addr; register struct areax *taxp; - int j, k, ramlimit; + int j, k, ramlimit, ramstart; char fchar=' ', dchar='a'; char ErrMsg[]="?ASlink-Error-Could not get %d consecutive byte%s" " in internal RAM for area %s.\n"; @@ -724,17 +746,27 @@ Addr_T lnksect2 (struct area *tap, int locIndex) /*Notice that only ISEG and SSEG can be in the indirectly addressable internal RAM*/ if( (!strcmp(tap->a_id, "ISEG")) || (!strcmp(tap->a_id, "SSEG")) ) { - if((iram_size<=0)||(iram_size>0x100)) - ramlimit=0x100; + if (iseg_ap) + ramstart = iseg_ap->a_addr; else - ramlimit=iram_size; + ramstart = 0; + + if ((iram_size <= 0) || (ramstart + iram_size > 0x100)) + ramlimit = 0x100; + else + ramlimit = ramstart + iram_size; } else { - if((iram_size<=0)||(iram_size>0x80)) - ramlimit=0x80; + if (dseg_ap) + ramstart = dseg_ap->a_addr; + else + ramstart = 0; + + if ((iram_size <= 0) || (ramstart + iram_size > 0x80)) + ramlimit = 0x80; else - ramlimit=iram_size; + ramlimit = ramstart + iram_size; } size = 0; @@ -790,28 +822,35 @@ Addr_T lnksect2 (struct area *tap, int locIndex) { while (taxp) { + if(taxp->a_size == 0) + { + taxp = taxp->a_axp; + continue; + } + if ( (fchar=='0')||(fchar=='1')||(fchar=='2')||(fchar=='3') ) /*Reg banks*/ { addr=(fchar-'0')*8; taxp->a_addr=addr; size=taxp->a_size; - for(j=addr; (j<(int)(addr+taxp->a_size)) && (ja_size=0; ja_size=0; j(int)taxp->a_size) taxp->a_size=k; + if((++k)>(int)taxp->a_size) + taxp->a_size=k; } else { @@ -827,37 +866,26 @@ Addr_T lnksect2 (struct area *tap, int locIndex) { size=(int)taxp->a_size; - for(j=0; ja_size) break; - } - if(k==(int)taxp->a_size) - { - taxp->a_addr = j-k+1; - if(addr<(unsigned int)ramlimit) - { - for(j=ramlimit-1; (j>=0)&&(idatamap[j]==' '); j--); - if(j>=0) addr=j+1; - } + break; } /*Mark the memory used for overlay*/ if(k==(int)taxp->a_size) { - for(j=taxp->a_addr; (j<(int)(taxp->a_addr+taxp->a_size)) && (ja_addr=addr; - taxp->a_addr=addr; - break; - } - } } else if (fchar=='T') /*Bit addressable bytes in internal RAM*/ { /*Find the size of the space currently used for this areax overlay*/ - for(j=0x20, size=0; j<0x30; j++) - if(idatamap[j]==fchar) size++; +// for(j=0x20, size=0; j<0x30; j++) +// if(idatamap[j]==fchar) size++; /*If more space required, release the previously allocated areax in internal RAM and search for a bigger one*/ @@ -900,27 +917,16 @@ Addr_T lnksect2 (struct area *tap, int locIndex) k++; else k=0; - if(k==(int)taxp->a_size) break; - } - - if(k==(int)taxp->a_size) - { - taxp->a_addr = j-k+1; - if(addr<(unsigned int)0x30) - { - for(j=0x2F; (j>=0x20)&&(idatamap[j]==' '); j--); - if(j>=0x20) addr=j+1; - } + if(k==(int)taxp->a_size) + break; } /*Mark the memory used for overlay*/ - if(k==(int)taxp->a_size) + if(k==(int)size) { - for(j=taxp->a_addr; (j<(int)(taxp->a_addr+taxp->a_size)) && (j<0x30); j++) + addr = j-k+1; + for(j=addr; (j<(int)(addr+size)); j++) idatamap[j]=fchar; - - /*Set the new size of the data memory area*/ - size=ramlimit-addr; } else /*Couldn't find a chunk big enough: report the problem.*/ { @@ -929,17 +935,6 @@ Addr_T lnksect2 (struct area *tap, int locIndex) lkerr++; } } - - for(j=0x20; j<0x30; j++) - { - if (idatamap[j]==fchar) - { - addr=j; - tap->a_addr=addr; - taxp->a_addr=addr; - break; - } - } } else /*Overlay areas not in internal ram*/ { @@ -948,6 +943,13 @@ Addr_T lnksect2 (struct area *tap, int locIndex) } taxp = taxp->a_axp; } + /*Now set all overlayed areax to the same start address*/ + taxp = tap->a_axp; + while (taxp) + { + taxp->a_addr = addr; + taxp = taxp->a_axp; + } } else if (tap->a_flag & A_ABS) /* Absolute sections */ { @@ -955,14 +957,19 @@ Addr_T lnksect2 (struct area *tap, int locIndex) { if (locIndex == 0) { - for (j=taxp->a_addr; (j<(int)(taxp->a_addr+taxp->a_size)) && (ja_addr; (j<(int)(taxp->a_addr+taxp->a_size)) && (j<256); j++) + { + if (idatamap[j] == ' ') + idatamap[j] = 'A'; + else + fprintf(stderr, "memory overlap at 0x%X for %s\n", j, tap->a_id); + } } - if (locIndex == 1) + else if (locIndex == 1) { allocate_space(taxp->a_addr, taxp->a_size, tap->a_id, codemap); } - if (locIndex == 2) + else if (locIndex == 2) { allocate_space(taxp->a_addr, taxp->a_size, tap->a_id, xdatamap); } @@ -988,24 +995,21 @@ Addr_T lnksect2 (struct area *tap, int locIndex) if(taxp->a_size) { /*Search for a space large enough in internal RAM for this areax*/ - for(j=0, k=0; ja_size) break; + if(k==(int)taxp->a_size) + break; } if(k==(int)taxp->a_size) { taxp->a_addr = j-k+1; - if(addr<(unsigned int)ramlimit) - { - for(j=ramlimit-1; (j>=0)&&(idatamap[j]==' '); j--); - if(j>=0) addr=j+1; - size=ramlimit-addr; - } + + size += taxp->a_size; for(j=taxp->a_addr; (j<(int)(taxp->a_addr+taxp->a_size)) && (ja_size!=0) { - for(j=addr; j<((int)(addr+taxp->a_size)); j++) + /*Search for a space large enough in data memory for this areax*/ + for(j=0x20, k=0; j<0x30; j++) + { + if(idatamap[j]==' ') + k++; + else + k=0; + if(k==(int)taxp->a_size) break; + } + + /*Mark the memory used*/ + if(k==(int)taxp->a_size) + { + taxp->a_addr = j-k+1; + for(j=taxp->a_addr; (j<(int)(taxp->a_addr+taxp->a_size)) && (j<0x30); j++) idatamap[j]=fchar; + } + else /*Couldn't find a chunk big enough: report the problem.*/ + { + tap->a_unaloc=taxp->a_size; + fprintf(stderr, ErrMsg, taxp->a_size, taxp->a_size>1?"s":"", tap->a_id); + lkerr++; + } } - - taxp->a_addr = addr; - addr += taxp->a_size; size += taxp->a_size; taxp = taxp->a_axp; } diff --git a/as/mcs51/asmain.c b/as/mcs51/asmain.c index 86d0da26..a333ccea 100644 --- a/as/mcs51/asmain.c +++ b/as/mcs51/asmain.c @@ -483,6 +483,7 @@ asmbl() char fn[PATH_MAX]; char *p; int d, n, uaf, uf; + static struct area *abs_ap; /* pointer to current absolute area structure */ laddr = dot.s_addr; lmode = SLIST; @@ -870,18 +871,31 @@ loop: } newdot(ap); lmode = SLIST; + if (dot.s_area->a_flag & A_ABS) + abs_ap = ap; break; case S_ORG: if (dot.s_area->a_flag & A_ABS) { - outall(); - dot.s_area->a_size += dot.s_addr - dot.s_org; - laddr = dot.s_addr = dot.s_org = absexpr(); + char buf[NCPS]; + laddr = absexpr(); + sprintf(buf, "%s%x", abs_ap->a_id, laddr); + if ((ap = alookup(buf)) == NULL) { + ap = (struct area *) new (sizeof(struct area)); + *ap = *areap; + ap->a_ap = areap; + strncpy(ap->a_id, buf, NCPS); + ap->a_ref = areap->a_ref + 1; + ap->a_size = 0; + ap->a_fuzz = 0; + areap = ap; + } + newdot(ap); + lmode = ALIST; + dot.s_addr = dot.s_org = laddr; } else { err('o'); } - outall(); - lmode = ALIST; break; case S_RADIX: diff --git a/device/lib/printf_large.c b/device/lib/printf_large.c index 23501510..7d42abc2 100644 --- a/device/lib/printf_large.c +++ b/device/lib/printf_large.c @@ -211,6 +211,7 @@ output_float (float f, unsigned char reqWidth, pfn_outputchar output_char, void* p) { unsigned char charsOutputted = 0; + char fpBuffer[128]; #else #define OUTPUT_FLOAT(F, W, D, L, Z, S, P) output_float(F, W, D, L, Z, S, P) static void @@ -218,11 +219,11 @@ output_float (float f, unsigned char reqWidth, signed char reqDecimals, BOOL left, BOOL zero, BOOL sign, BOOL space) { + xdata char fpBuffer[128]; #endif //SDCC_STACK_AUTO BOOL negative = 0; unsigned long integerPart; float decimalPart; - char fpBuffer[128]; char fpBI=0, fpBD; unsigned char minWidth, i; diff --git a/src/SDCCglue.c b/src/SDCCglue.c index a4b8d4f8..704656eb 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -281,7 +281,7 @@ emitRegularMap (memmap * map, bool addPublics, bool arFlag) /* if it has an initial value then do it only if it is a global variable */ if (sym->ival && sym->level == 0) { - if (SPEC_OCLS(sym->etype)==xidata) { + if ((SPEC_OCLS(sym->etype)==xidata) && !SPEC_ABSA (sym->etype)) { /* create a new "XINIT (CODE)" symbol, that will be emitted later in the static seg */ newSym=copySymbol (sym); @@ -309,8 +309,6 @@ emitRegularMap (memmap * map, bool addPublics, bool arFlag) printIval (sym, sym->type, sym->ival, tmpFile); noAlloc--; } - - sym->ival=NULL; } else { if (IS_AGGREGATE (sym->type)) { ival = initAggregates (sym, sym->ival, NULL); @@ -338,12 +336,11 @@ emitRegularMap (memmap * map, bool addPublics, bool arFlag) allocInfo = 1; } } - sym->ival = NULL; } /* if it has an absolute address then generate an equate for this no need to allocate space */ - if (SPEC_ABSA (sym->etype)) + if (SPEC_ABSA (sym->etype) && !sym->ival) { char *equ="="; if (options.debug) { @@ -370,13 +367,17 @@ emitRegularMap (memmap * map, bool addPublics, bool arFlag) if (options.debug) { fprintf (map->oFile, "==.\n"); } + if (SPEC_ABSA (sym->etype)) + { + tfprintf (map->oFile, "\t!org\n", SPEC_ADDR (sym->etype)); + } if (IS_STATIC (sym->etype) || sym->level) tfprintf (map->oFile, "!slabeldef\n", sym->rname); else tfprintf (map->oFile, "!labeldef\n", sym->rname); - tfprintf (map->oFile, "\t!ds\n", - (unsigned int) size & 0xffff); + tfprintf (map->oFile, "\t!ds\n", (unsigned int) size & 0xffff); } + sym->ival = NULL; } } @@ -1346,6 +1347,8 @@ emitMaps (void) data, idata & bit & xdata */ emitRegularMap (data, TRUE, TRUE); emitRegularMap (idata, TRUE, TRUE); + emitRegularMap (d_abs, TRUE, TRUE); + emitRegularMap (i_abs, TRUE, TRUE); emitRegularMap (bit, TRUE, TRUE); emitRegularMap (pdata, TRUE, TRUE); emitRegularMap (xdata, TRUE, TRUE); @@ -1793,6 +1796,15 @@ glue (void) copyFile (asmFile, idata->oFile); } + /* 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); + copyFile (asmFile, d_abs->oFile); + copyFile (asmFile, i_abs->oFile); + } + /* copy the bit segment */ if (mcs51_like) { fprintf (asmFile, "%s", iComments2); diff --git a/src/SDCCglue.h b/src/SDCCglue.h index 0f078d2d..2113213c 100644 --- a/src/SDCCglue.h +++ b/src/SDCCglue.h @@ -41,7 +41,6 @@ extern set *pipeSet; extern set *tmpfileNameSet; void rm_tmpfiles (void); -int -pointerTypeToGPByte (const int p_type, const char *iname, const char *oname); +int pointerTypeToGPByte (const int p_type, const char *iname, const char *oname); #endif diff --git a/src/SDCCmain.c b/src/SDCCmain.c index a04aa579..8e9f367f 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -567,7 +567,7 @@ setDefaultOptions (void) options.code_loc = 0; /* code starts at 0 */ options.data_loc = 0; /* JCF: By default let the linker locate data */ options.xdata_loc = 0; - options.idata_loc = 0x80; + options.idata_loc = 0; /* MB: No need to limit idata to 0x80-0xFF */ options.nopeep = 0; options.model = port->general.default_model; options.nostdlib = 0; @@ -679,7 +679,7 @@ processFile (char *s) } /* if the extention is type .rel or .r or .REL or .R - addtional object file will be passed to the linker */ + additional object file will be passed to the linker */ if (strcmp (fext, ".r") == 0 || strcmp (fext, ".rel") == 0 || strcmp (fext, ".R") == 0 || strcmp (fext, ".REL") == 0 || strcmp (fext, port->linker.rel_ext) == 0) diff --git a/src/SDCCmem.c b/src/SDCCmem.c index 3be821ae..cb583388 100644 --- a/src/SDCCmem.c +++ b/src/SDCCmem.c @@ -17,6 +17,9 @@ 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 *x_abs = NULL; /* absolute xdata/pdata */ +memmap *i_abs = NULL; /* absolute idata upto 256 */ +memmap *d_abs = NULL; /* absolute data upto 128 */ memmap *sfr = NULL; /* register space */ memmap *reg = NULL; /* register space */ memmap *sfrbit = NULL; /* sfr bit space */ @@ -135,7 +138,7 @@ initMem () DEBUG-NAME - 'C' POINTER-TYPE - CPOINTER */ - home = allocMap (0, 1, 0, 0, 0, 1, options.code_loc, CODE_NAME, 'C', CPOINTER); + home = allocMap (0, 1, 0, 0, 0, 1, options.code_loc, HOME_NAME, 'C', CPOINTER); /* Static segment (code for variables ); SFRSPACE - NO @@ -173,6 +176,22 @@ initMem () */ data = allocMap (0, 0, 0, 1, 0, 0, options.data_loc, DATA_NAME, 'E', POINTER); + /* Absolute internal storage segment ; + SFRSPACE - NO + FAR-SPACE - NO + PAGED - NO + DIRECT-ACCESS - YES + BIT-ACCESS - NO + CODE-ACCESS - NO + 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; + } + /* overlay segment - same as internal storage segment ; SFRSPACE - NO FAR-SPACE - NO @@ -236,6 +255,22 @@ initMem () idata=NULL; } + /* Indirectly addressed absolute internal segment + SFRSPACE - NO + FAR-SPACE - NO + PAGED - NO + DIRECT-ACCESS - NO + BIT-ACCESS - NO + CODE-ACCESS - NO + 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; + } + /* Bit space ; SFRSPACE - NO FAR-SPACE - NO @@ -343,7 +378,7 @@ allocDefault (symbol * sym) if (sym->_isparm) return FALSE; /* if code change to constant */ - if (sym->ival && (sym->level==0) && SPEC_ABSA(sym->etype)) { + if (sym->ival && (sym->level==0) && SPEC_ABSA (sym->etype)) { SPEC_OCLS(sym->etype) = c_abs; } else { SPEC_OCLS (sym->etype) = statsg; @@ -352,17 +387,27 @@ allocDefault (symbol * sym) case S_XDATA: // should we move this to the initialized data segment? if (port->genXINIT && - sym->ival && (sym->level==0) && !SPEC_ABSA(sym->etype)) { + sym->ival && (sym->level==0) && !SPEC_ABSA (sym->etype)) { SPEC_OCLS(sym->etype) = xidata; } else { SPEC_OCLS (sym->etype) = xdata; } break; case S_DATA: - SPEC_OCLS (sym->etype) = 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; + } break; case S_IDATA: - SPEC_OCLS (sym->etype) = 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; + } sym->iaccess = 1; break; case S_PDATA: diff --git a/src/SDCCmem.h b/src/SDCCmem.h index a10d9e9b..9b212424 100644 --- a/src/SDCCmem.h +++ b/src/SDCCmem.h @@ -47,6 +47,8 @@ extern FILE *junkFile; #define OVERLAY_NAME port->mem.overlay_name #define CONST_NAME port->mem.const_name #define CABS_NAME port->mem.cabs_name +#define XABS_NAME port->mem.xabs_name +#define IABS_NAME port->mem.iabs_name /* forward definition for variables */ extern memmap *xstack; /* xternal stack data */ @@ -61,13 +63,15 @@ 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 *x_abs; /* absolute xdata/pdata */ +extern memmap *i_abs; /* absolute idata upto 256 */ +extern memmap *d_abs; /* absolute data upto 128 */ extern memmap *sfr; /* register space */ extern memmap *sfrbit; /* sfr bit space */ extern memmap *reg; /* register space */ extern memmap *generic; /* unknown */ extern memmap *overlay; /* the overlay segment */ -extern memmap *eeprom; /* eepromp space */ -extern memmap *eeprom; /* eepromp space */ +extern memmap *eeprom; /* eeprom space */ extern memmap *home; /* Non-banked home space */ extern int fatalError; diff --git a/src/avr/main.c b/src/avr/main.c index c2ea6a0c..982bc5c5 100644 --- a/src/avr/main.c +++ b/src/avr/main.c @@ -221,7 +221,10 @@ PORT avr_port = { "HOME", NULL, // initialized xdata NULL, // a code copy of xiseg - "CONST (CODE)", // const_name - const data (code or not) + "CONST (CODE)", // const_name - const data (code or not) + "CABS (ABS,CODE)", // cabs_name - const absolute data (code or not) + "XABS (ABS,XDATA)", // xabs_name - absolute xdata/pdata + "IABS (ABS,DATA)", // iabs_name - absolute idata/data NULL, NULL, 0, diff --git a/src/ds390/main.c b/src/ds390/main.c index dad9b748..11f515c3 100644 --- a/src/ds390/main.c +++ b/src/ds390/main.c @@ -883,6 +883,8 @@ PORT ds390_port = "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) + "XABS (ABS,XDATA)", // xabs_name - absolute xdata/pdata + "IABS (ABS,DATA)", // iabs_name - absolute idata/data NULL, NULL, 1 @@ -1200,6 +1202,8 @@ PORT tininative_port = NULL, "CONST (CODE)", // const_name - const data (code or not) "CABS (ABS,CODE)", // cabs_name - const absolute data (code or not) + "XABS (ABS,XDATA)", // xabs_name - absolute xdata/pdata + "IABS (ABS,DATA)", // iabs_name - absolute idata/data NULL, NULL, 1 @@ -1433,6 +1437,8 @@ PORT ds400_port = "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) + "XABS (ABS,XDATA)", // xabs_name - absolute xdata/pdata + "IABS (ABS,DATA)", // iabs_name - absolute idata/data NULL, NULL, 1 diff --git a/src/hc08/main.c b/src/hc08/main.c index b4f62c89..cd6eb0c0 100644 --- a/src/hc08/main.c +++ b/src/hc08/main.c @@ -438,8 +438,10 @@ PORT hc08_port = "HOME (CODE)", "XISEG", // initialized xdata "XINIT", // a code copy of xiseg - "CONST (CODE)", // const_name - const data (code or not) + "CONST (CODE)", // const_name - const data (code or not) "CABS (ABS,CODE)", // cabs_name - const absolute data (code or not) + "XABS (ABS)", // xabs_name - absolute xdata + "IABS (ABS)", // iabs_name - absolute data NULL, NULL, 1 diff --git a/src/mcs51/main.c b/src/mcs51/main.c index 6f122abc..8f7e4f61 100644 --- a/src/mcs51/main.c +++ b/src/mcs51/main.c @@ -755,6 +755,8 @@ PORT mcs51_port = "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) + "XABS (ABS,XDATA)", // xabs_name - absolute xdata/pdata + "IABS (ABS,DATA)", // iabs_name - absolute idata/data NULL, NULL, 1 diff --git a/src/pic/main.c b/src/pic/main.c index ad5e3b30..40a130b3 100644 --- a/src/pic/main.c +++ b/src/pic/main.c @@ -512,6 +512,8 @@ PORT pic_port = NULL, // xinit "CONST (CODE)", // const_name - const data (code or not) "CABS (ABS,CODE)", // cabs_name - const absolute data (code or not) + "XABS (ABS,XDATA)", // xabs_name - absolute xdata + "IABS (ABS,DATA)", // iabs_name - absolute data NULL, NULL, 1 // code is read only diff --git a/src/pic16/main.c b/src/pic16/main.c index 2a6e0678..ba45634f 100644 --- a/src/pic16/main.c +++ b/src/pic16/main.c @@ -1281,6 +1281,8 @@ PORT pic16_port = NULL, // xinit "CONST (CODE)", // const_name - const data (code or not) "CABS (ABS,CODE)", // cabs_name - const absolute data (code or not) + "XABS (ABS,XDATA)", // xabs_name - absolute xdata + "IABS (ABS,DATA)", // iabs_name - absolute data 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 0b0ae758..e07d7a95 100644 --- a/src/port.h +++ b/src/port.h @@ -38,9 +38,9 @@ /* definition of builtin functions */ typedef struct builtins { - char *name; /* name of builtin function */ - char *rtype; /* return type as string : see typefromStr */ - int nParms; /* number of parms : max 8 */ + char *name; /* name of builtin function */ + char *rtype; /* return type as string : see typefromStr */ + int nParms; /* number of parms : max 8 */ char *parm_types[MAX_BUILTIN_ARGS]; /* each parm type as string : see typeFromStr */ } builtins; @@ -180,6 +180,8 @@ typedef struct 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) + const char *xabs_name; // absolute xdata/pdata + const char *iabs_name; // absolute idata/data 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 */ diff --git a/src/xa51/main.c b/src/xa51/main.c index d7353dee..5ec0b74b 100755 --- a/src/xa51/main.c +++ b/src/xa51/main.c @@ -289,6 +289,8 @@ PORT xa51_port = "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) + "XABS (ABS,XDATA)", // xabs_name - absolute xdata + "IABS (ABS,DATA)", // iabs_name - absolute data NULL, // default local map NULL, // default global map 1 diff --git a/src/z80/main.c b/src/z80/main.c index 17451417..0a5592a1 100644 --- a/src/z80/main.c +++ b/src/z80/main.c @@ -678,6 +678,8 @@ PORT z80_port = NULL, /* xinit */ NULL, /* const_name */ "CABS", /* cabs_name */ + NULL, /* xabs_name */ + NULL, /* iabs_name */ NULL, NULL, 1 @@ -798,6 +800,8 @@ PORT gbz80_port = NULL, /* xinit */ NULL, /* const_name */ "CABS", /* cabs_name */ + NULL, /* xabs_name */ + NULL, /* iabs_name */ NULL, NULL, 1 diff --git a/support/regression/tests/absolute.c b/support/regression/tests/absolute.c index 40f35d2c..528ea543 100644 --- a/support/regression/tests/absolute.c +++ b/support/regression/tests/absolute.c @@ -24,3 +24,21 @@ testAbsolute(void) ASSERT(pI[0] == 0x1234); #endif } + +#if defined(SDCC_mcs51) || defined(SDCC_ds390) +volatile data at(0x20) unsigned char Byte0 = 0x00; +volatile data at(0x22) unsigned char Byte1 = 0x00; +volatile bit Bit0, Bit1, Bit2, Bit3, Bit4, Bit5, Bit6, Bit7, Bit8; +#endif + +void +testAbsBdata(void) +{ +#if defined(SDCC_mcs51) || defined(SDCC_ds390) + Bit0 = 1; + ASSERT(Byte0 == 0x00); + Byte0 = 0xFF; + Bit0 = 0; + ASSERT(Byte0 == 0xFF); +#endif +}