C51: WHEN/WHERE ARE GLOBAL AND STATIC VARIABLES INITIALIZED?
Information in this article applies to:
How does the compiler handle variables that are initialized when declared? If I write something like the following in a function:
static int temp = 1;
or initialize a global variable, how will the variable be initialized? I do not see anything in the STARTUP.A51 file to move initialized data from ROM to RAM.
The initial values of global and static variables are stored in ROM in a segment called ?C_INITSEG. They are then copied to the relevent RAM locations after the code in STARTUP.A51 has been executed and before the main() function is called. The code that performs the variable initialization may be found in the file INIT.A51 inside the LIB folder.
We strongly recommend that you do not modify the INIT.A51 file.
The following Discussion Forum threads may provide information related to this topic.
Last Reviewed: Friday, July 15, 2005
of your data.