<?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>local stack space and nested function calls</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/17749/local-stack-space-and-nested-function-calls</link><description> I have the following function calls and the number of bytes allocated on the local stack for each function. 
 
main() { 8.1 bytes allocated in local scope; call foo1() } 
foo1{ 49 bytes allocated call foo2() } 
foo2{ 278 bytes allocated call foo3() </description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: local stack space and nested function calls</title><link>https://community.arm.com/thread/96373?ContentTypeID=1</link><pubDate>Fri, 11 Jun 2004 08:26:13 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:bae3a9fa-4fe6-486b-a5b8-9843f3b72fde</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;C51 will have a hard time overlaying them all to fit them into 256 bytes of combined DATA/IDATA space&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Where it would try to fit them would depend on the memory model&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: local stack space and nested function calls</title><link>https://community.arm.com/thread/86824?ContentTypeID=1</link><pubDate>Fri, 11 Jun 2004 08:19:47 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:2e770ea4-f5cb-401b-a01d-9de78f47249c</guid><dc:creator>HansBernhard Broeker</dc:creator><description>&lt;p&gt;&lt;i&gt;does not use the stack for parameters and locals.&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Well, given that call tree, even Keil C51 will have a hard time overlaying them all to fit them into 256 bytes of combined DATA/IDATA space, as none of them would appear to be overlayable, from what he wrote.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: local stack space and nested function calls</title><link>https://community.arm.com/thread/42357?ContentTypeID=1</link><pubDate>Fri, 11 Jun 2004 07:42:35 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8d26f994-08ae-46de-be91-206399629778</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;You realise that C51 - unlike &amp;quot;normal&amp;quot; &amp;#39;C&amp;#39; compilers - does not use the stack for parameters and locals...?&lt;br /&gt;
&lt;br /&gt;
See the &lt;b&gt;manual&lt;/b&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: local stack space and nested function calls</title><link>https://community.arm.com/thread/50270?ContentTypeID=1</link><pubDate>Fri, 11 Jun 2004 07:37:42 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:644767b4-4430-4f80-b406-8789580a4424</guid><dc:creator>HansBernhard Broeker</dc:creator><description>&lt;p&gt;Assuming you&amp;#39;re actually correct that this many bytes are allocated on the stack, then your program would be completely broken, and the tools would have refused to build it (you&amp;#39;ld have blown the IDATA segment&amp;#39;s size).  No 8051 has 400+ bytes of stack.&lt;br /&gt;
&lt;br /&gt;
Which almost certainly means your analysis is incorrect.  But yes, if you have too much local data, in a deep call tree like this, you&amp;#39;ll run into problems like those you observed.  You&amp;#39;ll have to move some of the larger objects away from the stack and into XDATA.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>