#8 Fix for RFE 837937 and 846037

closed
nobody
None
5
2004-01-21
2003-12-22
Maarten Brock
No

Since I thought it couldn't be that difficult, I tried and
managed to implement this fix so that ISEG gets mapped
before SSEG. This makes it possible to store any
variables you cannot store in Direct Data Memory
anymore into Indirect Data Memory without having to
set --stack-loc or --idata-loc.

With this fixed, the next question will probably be to:
1) Use unused register space for DATA
2) Have a new memory model to populate DATA with
local variables and IDATA with global variables.
But that's for the next time.

Maarten Brock

Attached output of:

diff -ru sdcc/as/mcs51/lkmem.c sdcc-
new/as/mcs51/lkmem.c:

--- sdcc\as\mcs51\lkmem.c Wed Jul 23 17:58:02 2003
+++ sdcc-new\as\mcs51\lkmem.c Mon Dec 22
14:42:46 2003
@@ -74,7 +74,7 @@
{0, 0,
128, "TOTAL:", 0x0000}
};

- _Mem IRam= {0xff, 0, 128, "INDIRECT RAM",
0x0080};
+ _Mem IRam= {0xff, 0, 256, "INDIRECT RAM",
0x0080}; /* MB: Max should be 256, not 128 */
_Mem Stack={0xff, 0, 1, "STACK",
0x0000};
_Mem XRam= {0xffff, 0, 65536, "EXTERNAL
RAM", 0x0100};
_Mem Rom= {0xffff, 0,
65536, "ROM/EPROM/FLASH", 0x0200};
@@ -92,7 +92,7 @@
Ram[5].Max=0x80;
Ram[6].Max=0x80;
Ram[7].Max=0x80;
- IRam.Max=0x80;
+ IRam.Max=0x100; /* MB: Max should
be 256, not 128 */
iram_size=0x100;
}
else if(iram_size<0x80)
@@ -107,7 +107,7 @@
Ram[5].Max=0x80;
Ram[6].Max=0x80;
Ram[7].Max=0x80;
- IRam.Max=iram_size-0x80;
+ IRam.Max=iram_size; /* MB: Max
should be 256, not 128 */
}

for(j=0; j<(int)iram_size; j++) dram[j]=0;
@@ -328,7 +328,7 @@
fprintf(of, format, Rom.Name, start, end, size,
max);

/*Report any excess:*/
- if((IRam.Start+IRam.Size)>(IRam.Max+0x80))
+ if((IRam.Start+IRam.Size)>(IRam.Max)) /* MB:
Max should be 256, not 128 */
{
sprintf(buff, "Insufficient INDIRECT
RAM memory.\n");
REPORT_ERROR(buff, 1);

diff -ru sdcc/src/SDCCmain.c sdcc-new/src/SDCCmain.c:

--- sdcc\src\SDCCmain.c Wed Nov 26 17:32:30 2003
+++ sdcc-new\src\SDCCmain.c Mon Dec 22
15:06:16 2003
@@ -515,7 +515,7 @@
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: let the linker handle
this */
options.nopeep = 0;
options.model = port->general.default_model;
options.nostdlib = 0;
@@ -1358,8 +1358,9 @@
/* xdata start */
WRITE_SEG_LOC (XDATA_NAME,
options.xdata_loc);

- /* indirect data */
- if (IDATA_NAME) {
+ /* indirect data segment start. MB: If zero,
the linker chooses
+ the best place for indirect data*/
+ if ((IDATA_NAME) && (options.data_loc)) {
WRITE_SEG_LOC (IDATA_NAME,
options.idata_loc);
}

diff -ru sdcc/src/SDCCglue.c sdcc-new/src/SDCCglue.c:

--- sdcc\src\SDCCglue.c Thu Dec 18 22:23:36 2003
+++ sdcc-new\src\SDCCglue.c Mon Dec 22
12:37:55 2003
@@ -1706,6 +1706,15 @@
copyFile (asmFile, ovrFile);
}

+/* MB: first create idata, then stack */
+ /* create the idata segment */
+ if ( (idata) && (mcs51_like) ) {
+ fprintf (asmFile, "%s", iComments2);
+ fprintf (asmFile, "; indirectly addressable internal ram
data\n");
+ fprintf (asmFile, "%s", iComments2);
+ copyFile (asmFile, idata->oFile);
+ }
+
/* create the stack segment MOF */
if (mainf && IFFUNC_HASBODY(mainf->type))
{
@@ -1715,14 +1724,6 @@
fprintf (asmFile, "\t.area\tSSEG\t(DATA)\n"
"__start__stack:\n\t.ds\t1\n\n");
}
-
- /* create the idata segment */
- if ( (idata) && (mcs51_like) ) {
- fprintf (asmFile, "%s", iComments2);
- fprintf (asmFile, "; indirectly addressable internal ram
data\n");
- fprintf (asmFile, "%s", iComments2);
- copyFile (asmFile, idata->oFile);
- }

/* copy the bit segment */
if (mcs51_like) {

Discussion

  • Maarten Brock
    Maarten Brock
    2003-12-22

    zip containing diff output files

     
    Attachments
  • Stas Sergeev
    Stas Sergeev
    2004-01-01

    Logged In: YES
    user_id=501371

    In case you are wondering, this patch works for me
    (RFE 846037), thanks!
    Initially I expected to have that feature as an option:
    there can be a significant gap between the allocated data
    and idata, so it may probably still make sense to put the
    stack there in some cases. But as for me, this patch is
    sufficient, as I prefer to put the stack in idata even if
    some space in data still exist.

     
  • Maarten Brock
    Maarten Brock
    2004-01-21

    Logged In: YES
    user_id=888171

    The new -Wl-Y option does more than this patch. So I close
    this one.

     
  • Maarten Brock
    Maarten Brock
    2004-01-21

    • status: open --> closed