<?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>Data Space grows unexpectedly</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/20178/data-space-grows-unexpectedly</link><description> Hi all, 
I&amp;#39;ve noticed something strange with one of 
my 8051 projects. When I build the project, the build results show that I have used 98 bytes of data space . If I add the statement while(1) {} to the beginning of main(), my data space useage goes</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Data Space grows unexpectedly</title><link>https://community.arm.com/thread/138231?ContentTypeID=1</link><pubDate>Wed, 05 Jul 2006 18:42:20 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:18a1ad40-e1ac-434f-80fc-6a48864dede3</guid><dc:creator>Tony Zampini</dc:creator><description>&lt;p&gt;Drew,&lt;br /&gt;
Thanks for that clear explaination. Now I see why as I move the while(1) statement further and further down in main(), my data space useage gets smaller and smaller.&lt;br /&gt;
&lt;br /&gt;
Thanks again all.&lt;br /&gt;
Tony&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Data Space grows unexpectedly</title><link>https://community.arm.com/thread/134780?ContentTypeID=1</link><pubDate>Wed, 05 Jul 2006 12:44:42 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:51396bed-8479-40ce-86ed-e1745a02fe55</guid><dc:creator>Drew Davis</dc:creator><description>&lt;p&gt;The while(1) will cut off potentially many function calls from the call tree:&lt;br /&gt;
&lt;br /&gt;
A();&lt;br /&gt;
while (1);&lt;br /&gt;
B();&lt;br /&gt;
C();&lt;br /&gt;
D();&lt;br /&gt;
&lt;br /&gt;
B, C, and D will thus become roots of their own call tree, and any data memory needed by those call trees cannot be overlaid with that of the one with root at main (or A).&lt;br /&gt;
&lt;br /&gt;
while(0) does not have this effect, because it does not prevent the flow of control from reaching the later functions.&lt;br /&gt;
&lt;br /&gt;
The optimizer will eliminate the &lt;i&gt;calls&lt;/i&gt; to B, C, D.  But the linker will have to eliminate the body of those functions.  Either each function must be in its own C file (so that each winds up in its own segment) for the linker to omit the unneeded functions, or the new REMOVEUNUSED directive must be used with the linker to get rid of the uncalled code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Data Space grows unexpectedly</title><link>https://community.arm.com/thread/130061?ContentTypeID=1</link><pubDate>Wed, 05 Jul 2006 12:43:12 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5f7c5db0-3f25-4539-8f42-c042abc26fdf</guid><dc:creator>Tony Zampini</dc:creator><description>&lt;p&gt;OK, thanks folks. I think I have a handle on my problem now. I will experiment with the optimizer and work on the L16 warnings to see if I can prevent my data space from overflowing.&lt;br /&gt;
&lt;br /&gt;
Thanks again all,&lt;br /&gt;
Tony&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Data Space grows unexpectedly</title><link>https://community.arm.com/thread/123313?ContentTypeID=1</link><pubDate>Wed, 05 Jul 2006 12:35:10 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ca648451-c1ec-4d9c-99ad-48c5bfffbb54</guid><dc:creator>Christoph Franck</dc:creator><description>&lt;p&gt;&lt;i&gt;What exactly is the L16 warning telling me? &lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
That you need to consult the documentation on the topic of memory overlaying.&lt;br /&gt;
&lt;br /&gt;
Basically, the linker tries to figure out the calling relationship between functions. If there are two functions that do not call each other, then the local variables of these functions can be overlaid i.e. they occupy the same physical locations in memory.&lt;br /&gt;
&lt;br /&gt;
Uncalled functions are a problem. The linker has no way of knowing how they are called (from assembly ? through function pointers ?) and therefore has to put their local variables in unique memory location, which vastly inflates the amount of memory used.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Data Space grows unexpectedly</title><link>https://community.arm.com/thread/112206?ContentTypeID=1</link><pubDate>Wed, 05 Jul 2006 12:28:38 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:e6ffef38-c165-45b5-aef2-e74ccec11950</guid><dc:creator>Tony Zampini</dc:creator><description>&lt;p&gt;Erik,&lt;br /&gt;
Thanks for your reply. Yes, I do have L16 warnings, and I have many more when I include the while loop in main()!&lt;br /&gt;
&lt;br /&gt;
What exactly is the &lt;b&gt;L16&lt;/b&gt; warning telling me? I never fully understood this, and would really appreciate a clear explaination of it.&lt;br /&gt;
&lt;br /&gt;
Thanks in advance.&lt;br /&gt;
Tony&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Data Space grows unexpectedly</title><link>https://community.arm.com/thread/98240?ContentTypeID=1</link><pubDate>Wed, 05 Jul 2006 12:20:09 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:b5e1b4f2-4784-464c-9f25-27a7452282d6</guid><dc:creator>erik  malund</dc:creator><description>&lt;p&gt;optimizers are funny things, they do some thing well and screw up royally on others.  this is not a Keil thing, it is an optimizer thing.&lt;br /&gt;
&lt;br /&gt;
One guess : what if calls are optimized out, but called routines (in another module) are not.  That would explaim it.  Do you have L16 linker warnings?&lt;br /&gt;
&lt;br /&gt;
Erik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Data Space grows unexpectedly</title><link>https://community.arm.com/thread/74173?ContentTypeID=1</link><pubDate>Wed, 05 Jul 2006 12:14:23 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:42c25194-7622-4c0b-99e3-4cbdaeef52bd</guid><dc:creator>Tony Zampini</dc:creator><description>&lt;p&gt;Optimization? Good point. But putting a &lt;b&gt;while(1){}&lt;/b&gt; statement at the &lt;b&gt; beginning&lt;/b&gt; of main should allow the optimizer to &lt;b&gt;eliminate&lt;/b&gt; unused code and variables after the location of the while(1) statement. Instead, 63 more data space variables are allocated!&lt;br /&gt;
&lt;br /&gt;
Tony&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Data Space grows unexpectedly</title><link>https://community.arm.com/thread/46343?ContentTypeID=1</link><pubDate>Wed, 05 Jul 2006 12:07:53 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:4617b14e-d9db-4b13-8075-dd8e202ef3cb</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;Optimisation?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>