Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

memory allocation of volatile,const

Status
Not open for further replies.

bhadmanathan

Junior Member level 1
Junior Member level 1
Joined
May 7, 2016
Messages
18
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
187
Hi,
A typical memory representation of C program consists of following sections.

1. Text segment (program)
2. Initialized data segment (static/global)
3. Uninitialized data segment (static/global)
4. Stack (local variables,function calls)
5. Heap (dynamic allocation)

out of these five, where

local volatile variables
global volatile variables

local const variables
global const variables

string literals


will get stored...?

Only Text segment is ROM or every region has its ROM..?

And also...

In which time , memory for a variable will get allocated ? compile time or run time ?

I heard that only syntax errors are checked during compile time and memory will be allocated during run time. I dont understand it clearly. If it is wrong please explain me clearly..



Thanks in advance
 

Notice that you posted the question in PC programming rather than microcontrollers forum. In case of PC programs, the code is compiled for execution in RAM, it won't be able to run from ROM.

Generally, many answers depend on the runtime environment and compiler details.

The quoted memory layout is more typical for PC and RAM based embedded OS targets than ROM based microcontrollers. It would be reasonable to specify a target system when answering the questions.

To answer some general questions in advance.

The volatile qualifier is not particularly related to memory allocation. It's controlling the access to variable objects.

The const keyword primarly specifies that an object can't be modified at run time. Some compilers automatically move const objects to ROM by default, but the feasibility depends on the hardware architecture.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top