Where are static,constant variables stored?

Thread Starter

vinothmct

Joined Sep 24, 2012
14
I wish to know where data segment is implemented? Is it in RAM or ROM/Flash?

Our local variables are stored in stack which is implemented in RAM .

static , global variables are stored in data segmented is it implemnted in RAM? Is it so ? If will it lose contents when power is turned off?

Heap is implemented in RAM or Flash?
 

Papabravo

Joined Feb 24, 2006
22,111
You don't say which platform and you don't say which compiler or assembler.

The 'data' segment is normally implemented in RAM. It does lose its contents when the power goes away unless the RAM has a battery backup for the power supply.

The heap is part of the 'data' segment and shares the same properties as any other data stored in RAM.

Items declared 'const', 'flash', or 'eeprom' may be stored in non-volatile memory or they may be copied to RAM during initialization. It really depends on the platform and the compiler. So if you want an accurate answer; help us out won't you?
 

MrChips

Joined Oct 2, 2009
35,108
Either. It depends on the specific compiler.
Constants are usually stored in flash. However, compilers install an initialization routine that can initialize RAM variables. Hence the volatility of RAM is not an issue.
 

Thread Starter

vinothmct

Joined Sep 24, 2012
14
You don't say which platform and you don't say which compiler or assembler.

The 'data' segment is normally implemented in RAM. It does lose its contents when the power goes away unless the RAM has a battery backup for the power supply.

The heap is part of the 'data' segment and shares the same properties as any other data stored in RAM.

Items declared 'const', 'flash', or 'eeprom' may be stored in non-volatile memory or they may be copied to RAM during initialization. It really depends on the platform and the compiler. So if you want an accurate answer; help us out won't you?
LPCxpresso , IAR embedded Workbench . Does it entirely depend on the compiler? We can find it by reading compiler document?
 

Papabravo

Joined Feb 24, 2006
22,111
LPCxpresso , IAR embedded Workbench . Does it entirely depend on the compiler? We can find it by reading compiler document?
You might find it that way, but a faster way to find it is by looking at the compiler output. If the IAR compiler won't allow you to turn on an output listing and/or a linker map then you need to locate the objdump utility which is part of the GNU compiler chain.
 
Top