| ||||||||
Technical Support Support Resources Product Information | BL51: HOW DOES OVERLAY ANALYSIS WORK?Information in this article applies to:
QUESTIONHow does overlay analysis work in the C51 tools? ANSWERThe C51 tools are designed to make optimal use of the limited memory resources of the 8051 microcontroller. To provide the most efficient use of memory, automatic variables and function arguments are overlaid in memory according to a well-defined procedure. First, the linker builds a call tree of your program. For example: OVERLAY MAP OF MODULE: SAMPLE (SAMPLE) SEGMENT DATA_GROUP +--> CALLED SEGMENT START LENGTH ---------------------------------------------- ?C_C51STARTUP ----- ----- +--> ?PR?MAIN?SAMPLE ?PR?MAIN?SAMPLE 0009H 0001H +--> ?PR?GETCHAR?GETCHAR +--> ?PR?_TOUPPER?TOUPPER +--> ?PR?PUTCHAR?PUTCHAR ?PR?GETCHAR?GETCHAR ----- ----- +--> ?PR?_GETKEY?_GETKEY +--> ?PR?PUTCHAR?PUTCHAR This table is built by analyzing the references within a function to program segments (?PR?) and constant code segments (?CO?). In this example, you can see that ?C_C51STARTUP references (calls) the MAIN function. The MAIN function references (calls) GETCHAR, TOUPPER, and PUTCHAR. And GETCHAR references (calls) GETKEY and PUTCHAR. By building a call tree, the linker can figure out which data segments for which functions are mutually exclusive and can overlay them. For example, suppose that the MAIN C function calls function A, function B, and function C. Function A uses 10 bytes of automatic variables. Function B uses 20 bytes of automatic variables. And, function C uses 16 bytes of automatic variables. Assuming that functions A, B, and C do not call each other, the memory they use may be overlaid. So, rather than taking 46 bytes of data memory (10 for A + 20 for B + 16 for C) only 20 bytes of data memory are consumed. The overlaid memory is called DATA_GROUP (for the DATA space variables that are overlaid), BIT_GROUP (for the BIT space variables that are overlaid), and XDATA_GROUP (for the XDATA space variables that are overlaid). MORE INFORMATION
SEE ALSO
FORUM THREADSThe following Discussion Forum threads may provide information related to this topic. Last Reviewed: Friday, July 15, 2005 | |||||||
| ||||||||