From: Maarten B. <sou...@ds...> - 2007-11-09 08:16:44
|
Hello Eric, Actually the 8051 has much more memory spaces. A program space called code memory, an external memory space called xdata, an internal memory space called idata and an sfr space which is only direct-addressable. Half of the idata is also direct-addressable and called data memory when used as such. Inside this data space there is a part that is also bit-addressable (bit) and another part is also used to store the registers. For more information on this search on the internet for "8051 bible" and look in the datasheet. The large memory model indeed puts all variables in xdata. But this memory is only indirectly addressable and always needs both dptr and acc to do that. In order to get anything done the compiler needs to copy its contents to registers and if it runs out of them to data memory. This is called spilling. If your program is large and complex enough you can still run out of data memory. I recommend to switch to a smaller memory model and move large variables to xdata by hand. An alternative might be to switch to stack-auto which tries to put all local variables on the stack. But check that you do not overflow your stack, because the compiler can not do that. HTH, Maarten > I've been struggling with the 8051 memory models and using SDCC on a > Silicon Labs c8051f340-series chip for a few days now, and I was hoping > someone could help. Extensive googling has been less than helpful. > > As I understand it the 8051 has two memory spaces -- a program space > and a data space. In the data space, for a chip like the si c8051f34x, > the data memory space's lower 256 bytes are registers, sfrs, etc. > Everything up to 0x800 is then on-chip xdata memory, that can be > accessed via movx. > > The large memory model is supposed to locate all variables in this xdata > space, right? So by linking with: > > sdcc -o mmc.ihx --model-large --xram-loc 0x100 main.rel mmc.rel > diskiommc.rel diskio.rel tff.rel > > All static variables, in-function variables, etc. should be accessed > with movx instructions via dptr? > > When I try building my project, it bombs out with > > > ?ASlink-Error-Could not get 137 consecutive bytes in internal RAM for > area DSEG. > make: *** [mmc.ihx] Error 1 > > I'm not clear why SDCC still wants internal memory in the large model! > Is this a bug -- or more likely, an error in my understanding of SDCC? > > (I've stuck my makefile and code at web.mit.edu/jonas/Public/8051.zip if > anyone wants to reproduce the result for themselves) > > Thanks! > ...Eric > > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Sdcc-user mailing list > Sdc...@li... > https://lists.sourceforge.net/lists/listinfo/sdcc-user > |