AT89S52 (8051 family) + SDCC

Thread Starter

GabrielSalla

Joined Jul 6, 2013
6
Hello everyone
I've searched about my problem and I didn't find something that helped.
I have a C program for 89s52 (8051 family) with SDCC and the aim of the project is to have the best memory efficiency I can. I need to allocate the largest array for data without having a stack overflow.
Here is the .mem of the program:
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|Q|Q| | | | | | | | | | | | |
0x20:|B|T|I|I|I|I|I|I|I|I|I|I|I|I|I|I|
0x30:|I|I|I|I|I|I|I|I|I|I|I|I|I|I|I|I|
0x40:|I|I|I|I|I|I|I|I|I|I|I|I|I|I|I|I|
0x50:|I|I|I|I|I|I|I|I|I|I|I|I|I|I|I|I|
0x60:|I|I|I|I|I|I|I|I|I|I|I|I|I|I|I|I|
0x70:|I|I|I|I|I|I|I|I|I|I|I|I|I|I|I|I|
0x80:|I|I|I|I|I|I|I|I|I|I|I|I|I|I|I|I|
0x90:|I|I|I|I|I|I|I|I|I|I|I|I|I|I|I|I|
0xa0:|I|I|I|I|I|I|I|I|I|I|I|I|I|I|I|I|
0xb0:|I|I|I|I|I|I|I|I|I|I|I|I|I|I|I|I|
0xc0:|I|I|I|I|I|I|I|I|I|I|I|I|I|I|I|I|
0xd0:|I|I|I|I|I|I|I|I|I|I|I|I|I|I|I|I|
0xe0:|I|I|I|I|I|I|I|I|I|I|S|S|S|S|S|S|
0xf0:|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|
0-3:Reg Banks, T:Bit regs, a-z:Data, B:Bits, Q:Overlay, I:iData, S:Stack, A:Absolute
Stack starts at: 0xea (sp set to 0xe9) with 22 bytes available.

The "I"s is my 'short int' (2 bytes for each position) array that is stored as idata.
I've found that 22 bytes for stack is enough, and if I increase the size of the array by 1 (20 bytes for stack), the program stops working.
But I've noticed that the compiler reserved the adresses 0x20 and 0x21 for bits and nowhere in my program I've used bits variables. Looking at the .asm generated, I saw the allocation but the program don't use it anywhere...
If I can remove these bits variables, It would be possible to have 14 more bytes in my array.
I can't increase the size to use the free space before 0x20 because these 2 bytes are in the way :(
Someone know how to solve it?

PS: Sorry about any mistake with my english. English is not my first language ^^
 
Top