| Details |
Message |
|
Read-Only
Author bhaskar reddy
Posted 25-Apr-2012 17:23 GMT
Toolset C251
|
 Global varible or Local varibles which is best wrt data memory usage?
bhaskar reddy
Hi , Which is best local or global variables wrt data memory ?I
observed that XData size is getting reduced when I am replacing my
global variable with local variable.is there any effect on internal
data memory if I use local variable instead of global variables?and
what about the performance? I am waiting for your valuable
suggestions..
With Regards,
Bhaskar Reddy
bhaskar@blazeautomation.com
|
|
|
Read-Only
Author Per Westermark
Posted 25-Apr-2012 18:15 GMT
Toolset C251
|
 RE: Global varible or Local varibles which is best wrt data memory usage?
Per Westermark
Can you first confirm that it really is a C251 you are using and
not the C51 compiler.
|
|
|
Read-Only
Author bhaskar reddy
Posted 25-Apr-2012 18:31 GMT
Toolset C251
|
 RE: Global varible or Local varibles which is best wrt data memory usage?
bhaskar reddy
Thakns for your reply, I am using p89v51RD2 micro controller and
Keil software.
With regards,
Bhaskar
|
|
|
Read-Only
Author Andrew Neil
Posted 25-Apr-2012 20:08 GMT
Toolset None
|
 Things to think about...
Andrew Neil
For how long does a global variable occupy its place in
memory?
For how long does a local variable occupy its place in memory?
|
|
|
Read-Only
Author Frustrated Consultant
Posted 26-Apr-2012 07:25 GMT
Toolset None
|
 Partial answers
Frustrated Consultant
It would be worth you reading up on memory models.
http://www.keil.com/support/man/docs/c51/c51_le_memmodels.htm
For how long does a global variable occupy its place in
memory?
For how long does a local variable occupy its place in
memory?
Well now, if the local variable happens to be declared as static,
then the lifetime will be the same.
Likewise, if the linker directive of NOOVERLAY is used, then the
overall memory usage will be the same.
No?
|
|
|
Read-Only
Author Andrew Neil
Posted 26-Apr-2012 17:30 GMT
Toolset None
|
 RE: Partial answers
Andrew Neil
"if the local variable happens to be declared as static, then
the lifetime will be the same"
Correct - thus showing a flaw in the original question.
"if the linker directive of NOOVERLAY is used, then the overall
memory usage will be the same"
Yes.
|
|
|
Read-Only
Author Andrew Neil
Posted 26-Apr-2012 18:07 GMT
Toolset C51
|
 RE: if the linker directive of NOOVERLAY is used
Andrew Neil
Or optimisation level below 2:
http://www.keil.com/support/man/docs/c51/c51_optimize.htm
|
|
|
Read-Only
Author Frustrated Consultant
Posted 26-Apr-2012 18:56 GMT
Toolset C51
|
 What if all experts answered in that manner?
Frustrated Consultant
Correct - thus showing a flaw in the original question.
Yes, you should be more careful in how you pose them next
time.
Or optimisation level below 2:
Correct.
|
|
|
Read-Only
Author Andrew Neil
Posted 26-Apr-2012 23:30 GMT
Toolset None
|
 RE: you should be more careful in how you pose them next time
Andrew Neil
I was kinda hoping that the OP would realise the issue in his
thinking, but you gave it away - so I doubt he'll be doing any
thinking at all now.
|
|
|
Read-Only
Author Frustrated Consultant
Posted 27-Apr-2012 06:43 GMT
Toolset None
|
 High horses
Frustrated Consultant
I was kinda hoping that the OP would realise the issue in his
thinking, but you gave it away - so I doubt he'll be doing any
thinking at all now.
OMG. I'm so tempted to say what I really think of what you wrote
there, but I'll bite my tongue.
You believe the OP understood the nuances of what I wrote in
response to your questions? genuinely?
|
|
|
Read-Only
Author ashley madison
Posted 26-Apr-2012 23:15 GMT
Toolset C251
|
 RE: Global varible or Local varibles which is best wrt data memory usage?
ashley madison
Which is best local or global variables wrt data memory
?
both are the best.
|
|