<?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>RE: PUSH and POP in Keil C</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/19778/re-push-and-pop-in-keil-c</link><description> First and foremost, understand you make no contribution to this forum by replying to every thread with &amp;#39;read the manual&amp;#39;. If you do not wish to answer the question, simply dont answer it. 
 
 
To answer the question, KEIL C has the commands (probably</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: RE: PUSH and POP in Keil C</title><link>https://community.arm.com/thread/97833?ContentTypeID=1</link><pubDate>Fri, 03 Feb 2006 13:46:53 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d5a2f295-67ca-4ef3-b644-249846739572</guid><dc:creator>Drew Davis</dc:creator><description>&lt;p&gt;A local variable often makes a good alternative to push&amp;#39;ing and pop&amp;#39;ing from C.  For example:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;
void MyFunc (void)
    { // accesses slow devices
    U8 oldCkcon = CKCON;
    CKCON = SlowCkcon;

    // slow accesses here

    CKCON = oldCkcon;  // normal speed
    }
&lt;/pre&gt;
&lt;br /&gt;
When using this style, it helps to remember the somewhat obscure feature of C that you can declare unnamed local blocks of code:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;
void MyFunc (void)
    {
    // some variables

    // some code that runs fast

    { // slow access region
    U8 oldCkcon = CKCON;
    CKCON = SlowCkcon;

    // slow accesses here

    CKCON = oldCkcon;
    } // end of slow access

    // more code here that runs fast
    }
&lt;/pre&gt;
&lt;br /&gt;
This makes a nice visual marker for the critical region, as well as limiting the scope of the variable only to where it&amp;#39;s needed.&lt;br /&gt;
&lt;br /&gt;
Unfortunately, the C51 overlay analysis does not optimize handling of such local blocks within a function.  All the variables declaring within such are apparently promoted outside to the &amp;quot;real&amp;quot; function.  So, if I wrote three blocks like this in a row within one function, I&amp;#39;d wind up with 3 U8s reserved by that function, even though only one of them is used at a time, and the storage could be safely reused.  On the bright side, these critical regions map 1:1 directly to functions more often that not.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RE: PUSH and POP in Keil C</title><link>https://community.arm.com/thread/87574?ContentTypeID=1</link><pubDate>Fri, 03 Feb 2006 02:37:58 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:c265d0ab-3065-4d64-ab3d-ffeb4655447b</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;Remember push/pop can SAVE or RESTORE any special function register.&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Also remember that you have absolutely no control whatsoever of what else the compiler may be PUSHing and POPping, nor when it might be doing it!&lt;br /&gt;
&lt;br /&gt;
Therefore, to insert abitrary PUSHes and POPs into &amp;#39;C&amp;#39; source code must be regarded as dangerous in the extreme!!  :-0&lt;br /&gt;
&lt;br /&gt;
See &lt;a href="http://www.keil.com/forum/docs/thread7162.asp#msg33283"&gt;http://www.keil.com/forum/docs/thread7162.asp#msg33283&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RE: PUSH and POP in Keil C</title><link>https://community.arm.com/thread/45489?ContentTypeID=1</link><pubDate>Fri, 03 Feb 2006 02:32:01 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:166ec59a-d231-4b00-82df-dfedb77fd12f</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;you make no contribution to this forum by replying to every thread with &amp;#39;read the manual&amp;#39;&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
And what contribution do you make by providing an &amp;quot;answer&amp;quot; with no reference to any corresponding question?!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>