Hello Sdcc users,

I've been using sdcc for a year or two, thanks to all the developers for the 
sdcc project.

I'm writing to ask for help understanding how to manage ram usage with the 
mcu8051.  I've read over the sdcc manual several times and have searched 
through the mailing list history.  I'm hoping that someone can point me in the 
right direction.

The issue is that with a __bit variable defined, and several dozen __data 
variables defined, there is a large gap of unused ram between the register bank 
and the bit variable.

I'm sure I could force usage of the unused ram locations by using absolute 
'__at' addresses, but perhaps there's a way for sdcc to manage the ram layout 
automatically.

Here is some sample code.  This sample includes a function to demonstrate 
overlay variables, which is shown in the memory map.  Take out the function and 
you'll get the same results.  I included the function to show that overlay 
variables work nicely.

// start of code sample
// SDCC : mcs51/gbz80/z80/z180/r2k/r3ka/ds390
// /pic16/pic14/TININative/ds400/hc08/s08
// 3.2.0 #8008 (Jul  6 2012) (MINGW32)
#include <8052.h>

char  oneChar1[24];
char  oneChar2;

__bit oneBit = 0;

void delay(int jj, int kk)
{
    int j;
    int k;
    for(k=0; k < kk; k++) {
        for(j=0; j < jj; j++) {
        }
    }
}

void main(void)
{

    while(1) {
        delay(100,200);
    }
}
// end of code sample

Here is a portion of the memory map, showing the large gap of unused data ram:

Internal RAM layout:
      0 1 2 3 4 5 6 7 8 9 A B C D E F
0x00:|0|0|0|0|0|0|0|0|Q|Q| | | | | | |
0x10:| | | | | | | | | | | | | | | | |
0x20:|B|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|
0x30:|a|a|a|a|a|a|a|a|a|a|S|S|S|S|S|S|

Comment out the __bit variable and this is the memory map that results.  You 
can see the __data variables start right after register bank 0, followed by the 
QQ overlay variables.

Internal RAM layout:
      0 1 2 3 4 5 6 7 8 9 A B C D E F
0x00:|0|0|0|0|0|0|0|0|a|a|a|a|a|a|a|a|
0x10:|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|
0x20:|a|Q|Q|S|S|S|S|S|S|S|S|S|S|S|S|S|
0x30:|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|

Restore the __ bit variable and comment out the 'char oneChar2' variable and 
you get this memory map, showing the __bit variable between the __data 
variables and the overlay variables.

Internal RAM layout:
      0 1 2 3 4 5 6 7 8 9 A B C D E F
0x00:|0|0|0|0|0|0|0|0|a|a|a|a|a|a|a|a|
0x10:|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|
0x20:|B|Q|Q|S|S|S|S|S|S|S|S|S|S|S|S|S|
0x30:|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|

Hope all this makes sense.

Thanks for your time, 
Rich.

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to