<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Global Vs Local Variable</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/33331/global-vs-local-variable</link><description> 
I have all global variables in my project. Since RAM data size has
almost become full, i wanted to replace some of the global variables
with local variables in functions. But each local variable
declaration seems to take up RAM space as if it is a global</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Global Vs Local Variable</title><link>https://community.arm.com/thread/108676?ContentTypeID=1</link><pubDate>Wed, 24 Feb 2016 05:50:28 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:08a38cd8-1c2c-4474-b247-7ed556ea4837</guid><dc:creator>&amp;#178;erik malund</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;I have all global variables in my project. Since RAM data size
has almost become full, i wanted to replace some of the global
variables with local variables in functions. But each local variable
declaration seems to take up RAM space as if it is a global
variable;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Per explains very well above, one thing to add: if you use
function pointers you will see exactly &lt;i&gt;each local variable
declaration seems to take up RAM space as if it is a global
variable;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
another thing, the &amp;#39;overlaying&amp;#39; Per describes above requires
optimizer level 2 (or above)&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Global Vs Local Variable</title><link>https://community.arm.com/thread/93693?ContentTypeID=1</link><pubDate>Wed, 24 Feb 2016 03:03:30 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:98882d55-4a02-4acd-9bc1-d564cb1be43a</guid><dc:creator>edPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
Since the 8051 has lousy instructions for stack-relative memory
accesses the compiler converts local data into global data. But it
evaluates the call tree to find out which functions will be called in
a chain and which functions will never be called at the same
time.&lt;/p&gt;

&lt;p&gt;
This allows the compiler to overlay multiple &amp;quot;local&amp;quot; variables in
the same global address space. So you can save space by having local
variables.&lt;/p&gt;

&lt;p&gt;
In some situations, you can add more &amp;quot;local&amp;quot; variables without
increasing the data space. In some situations, the compiler will have
to allocate more global data space because of the call tree
analysis.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Global Vs Local Variable</title><link>https://community.arm.com/thread/64534?ContentTypeID=1</link><pubDate>Wed, 24 Feb 2016 01:52:34 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d9d2c041-b417-4b2d-a6bc-c57ba26604cc</guid><dc:creator>Westonsupermare Pier</dc:creator><description>&lt;p&gt;&lt;p&gt;
The 8051 compiler doesn&amp;#39;t use the stack for locals in the manner
an x86 or ARM compiler does.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>