Hi,
I have 2 pieces of software that both independently work correctly. When combined, however, they don't seem to get on. I think my problem is concerned with memory space corruption. ie. one module's data overwriting the other's.
Here are some excerpts from the appropriate .LST files:
MODULE INFORMATION: STATIC OVERLAYABLE CODE SIZE = 2404 ---- CONSTANT SIZE = ---- ---- XDATA SIZE = 1024 ---- PDATA SIZE = ---- ---- DATA SIZE = 2 114 IDATA SIZE = 37 ---- BIT SIZE = 1 2 END OF MODULE INFORMATION. MODULE INFORMATION: STATIC OVERLAYABLE CODE SIZE = 894 ---- CONSTANT SIZE = ---- ---- XDATA SIZE = ---- ---- PDATA SIZE = ---- ---- DATA SIZE = ---- 23 IDATA SIZE = ---- 44 BIT SIZE = ---- ---- END OF MODULE INFORMATION. MODULE INFORMATION: STATIC OVERLAYABLE CODE SIZE = 326 ---- CONSTANT SIZE = 328 ---- XDATA SIZE = ---- ---- PDATA SIZE = ---- ---- DATA SIZE = ---- 18 IDATA SIZE = ---- 36 BIT SIZE = ---- ---- END OF MODULE INFORMATION.
Can anybody please explain for me the difference between static and overlayable memory allocations? I'd like to know from the above how I can tell if I have filled either the DATA or IDATA memory spaces. How would I be certain that I am experiencing memory space corruption? My processor is an AT89C51AC2.
Regards, Murray R. Van Luyn.
Static variables are those given fixed locations. Like globals and variables declared static. the rest (automatic variables) only exist while the function that declares them is in use. Most C friendly CPUs use the CPU's hardware stack for these variables. the RAM is reused after the function is exited. Since the 8052 has a tiny stack Keil calculates the addresses for these variables and determines which can be located in the same location (Overlaying).
The compiler will handle this unless you are using function pointers, recursion, or calling functions from main and an interrupt.
A more like issue is that you ran out of RAM and the Stack is over writing the variables.
"The compiler will handle this unless you are using function pointers, recursion, or calling functions from main and an interrupt."
Note that the compiler doesn't take any specific account of these things - it's up to you to ensure that your application is "overlay-safe"
Effectively, "Overlaying" does at build time what "normal" compilers do (by using the stack) at run time.
The Compiler or Assembler mark data as Overlayable or not;
The Linker performs the actual overlaying:
http://www.keil.com/support/man/docs/lx51/lx51_overlaying.htm
http://www.keil.com/support/man/docs/bl51/bl51_overlaying.htm http://www.keil.com/support/man/docs/bl51/bl51_in_overlaying.htm
Thanks Neil & Andy.
Hmm..I don't think I've done anything to blow the stack. I'm passing very little to my printf() functions, and that's the only time I've ever encountered stack overflow.
I think I understand how program data can be either static or overlayable, and that the toolset looks after combining any overlayable storage.
Please correct me if I am wrong. My AT89C51AC2 has 80 bytes, and a further 128 bits in it's DATA memory space. IDATA comprises of a further 128 bytes of storage. There is a tiny stack space in one of these storage regions, but I don't know how large it is, nor where it is located?
Previously, I have had too many variables occupying my DATA memory space, and there were consequently unwanted interactions between these variables. The situation was resolved by simply shifting some variables to IDATA. Now I would like to see if I have the same situation again.
Is it possible to determine the precise DATA and IDATA memory space occupancy from the static and overlayable memory requirements of the module set? (ie. from the figures quoted in the .LST files) Can I just add up the static and overlayable contributions from each of the modules to get total memory space consumption? Do I add the individual overlayable memory requirements from each of my modules as I would expect to add static requirements? Do overlayable segments somehow consume less than their sum?
That information is in the Linker Listing or "map" file.
View all questions in Keil forum