<?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>how many registers are pushed into the stack when running an ISR ?</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/21975/how-many-registers-are-pushed-into-the-stack-when-running-an-isr</link><description> 
I want to change the return address in the stack when running an
ISR so that it returns to the specified address. But i found the
compiler also pushes some variables to the stack. How can I configure
the complier so that it only pushes all registers</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: how many registers are pushed into the stack when running an ISR ?</title><link>https://community.arm.com/thread/138521?ContentTypeID=1</link><pubDate>Mon, 13 Aug 2007 12:17:43 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:54204277-3f5d-4c2e-abe8-efe3d11e1b39</guid><dc:creator>erik  malund</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;On a first glance, FreeRTOS also seems to support round-robin
scheduling&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
if so, why on earth even involve a RTOS?&lt;/p&gt;

&lt;p&gt;
Erik&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how many registers are pushed into the stack when running an ISR ?</title><link>https://community.arm.com/thread/138530?ContentTypeID=1</link><pubDate>Mon, 13 Aug 2007 09:36:21 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:267c9c45-95dd-42f7-827b-fec71dd4ac6a</guid><dc:creator>cress w</dc:creator><description>&lt;p&gt;&lt;p&gt;
i will look at it in more details. thanks.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how many registers are pushed into the stack when running an ISR ?</title><link>https://community.arm.com/thread/135089?ContentTypeID=1</link><pubDate>Mon, 13 Aug 2007 09:32:03 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:eb9d19ed-7735-4858-8b9d-f7b7b7c7de24</guid><dc:creator>Christoph Franck</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;the scheduling policy in my RTOS is not priority based.
therefore i can not use FreeRTOS.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
On a first glance, FreeRTOS also seems to support round-robin
scheduling and cooperative multitasking, too.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how many registers are pushed into the stack when running an ISR ?</title><link>https://community.arm.com/thread/124006?ContentTypeID=1</link><pubDate>Mon, 13 Aug 2007 08:52:33 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:bc3fa5b7-551b-40b9-9f15-a3963bb90664</guid><dc:creator>cress w</dc:creator><description>&lt;p&gt;&lt;p&gt;
the scheduling policy in my RTOS is not priority based. therefore
i can not use FreeRTOS.&lt;/p&gt;

&lt;p&gt;
thank all of your replys.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how many registers are pushed into the stack when running an ISR ?</title><link>https://community.arm.com/thread/123997?ContentTypeID=1</link><pubDate>Mon, 13 Aug 2007 08:33:12 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f3907264-440f-4b4d-8111-b7c550a5c9e5</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot;Can you confirm that when the Keil complier...&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
If it&amp;#39;s not explicitly documented, then you &lt;b&gt;must &lt;i&gt;not&lt;/i&gt;&lt;/b&gt;
rely upon it!&lt;/p&gt;

&lt;p&gt;
Just don&amp;#39;t take the risk - this really does need to be done in
&lt;b&gt;&lt;i&gt;pure&lt;/i&gt; assembler!&lt;/b&gt;.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how many registers are pushed into the stack when running an ISR ?</title><link>https://community.arm.com/thread/113103?ContentTypeID=1</link><pubDate>Mon, 13 Aug 2007 08:28:06 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:85f08d84-449a-4d79-9ca9-8b09be39c223</guid><dc:creator>cress w</dc:creator><description>&lt;p&gt;&lt;p&gt;
Thanks, Christoph.&lt;/p&gt;

&lt;p&gt;
I did write the timer ISR in a mix of C and assembly. Can you
confirm that when the Keil complier complies an ISR, it only pushes
all registers into the system stack at the beginning please?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how many registers are pushed into the stack when running an ISR ?</title><link>https://community.arm.com/thread/113094?ContentTypeID=1</link><pubDate>Mon, 13 Aug 2007 07:59:49 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d9e39493-ea83-4748-98f7-b9cd8c5bcee9</guid><dc:creator>Arthur Plank</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;This is actually one of the few cases where manually changing
the return address might be necessary.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Agreed.&lt;/p&gt;

&lt;p&gt;
You really should consider writing this portion in assembler. You
will then be in total control, the execution order and size of the
code will them be more predictable, and you should (therefore) have a
more reliable solution.&lt;/p&gt;

&lt;p&gt;
Have you considered freeRTOS?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how many registers are pushed into the stack when running an ISR ?</title><link>https://community.arm.com/thread/99518?ContentTypeID=1</link><pubDate>Mon, 13 Aug 2007 07:51:05 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:9022e07b-57a9-4e81-82b8-4789847a6458</guid><dc:creator>Christoph Franck</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;i want to do context switch within the timer ISR.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Ok. This is actually one of the few cases where manually changing
the return address might be necessary.&lt;/p&gt;

&lt;p&gt;
However, think about what the term &lt;b&gt;context&lt;/b&gt; implies. A
context switch is not done by just setting the program counter to the
new address. Each context also has its own registers and (usually)
stack (pointer). If you are working with C, then the context can
include even more variables (for example any variable used inside one
of the libraries you use).&lt;/p&gt;

&lt;p&gt;
You probably won&amp;#39;t be able to avoid using assembly in your OS. You
can write the task switcher in a mix of assembly and C (start and end
with assembly, call a function in C) if it is too complex to be
written in pure assembly. On the plus side, using assembly will give
you complete control over which registers are pushed to the
stack.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how many registers are pushed into the stack when running an ISR ?</title><link>https://community.arm.com/thread/75369?ContentTypeID=1</link><pubDate>Mon, 13 Aug 2007 07:40:11 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:145f900e-68c5-4100-99e7-8afa106a6e5d</guid><dc:creator>cress w</dc:creator><description>&lt;p&gt;&lt;p&gt;
Thank you for your quick response.&lt;/p&gt;

&lt;p&gt;
I am programming a simple RTOS with 8051. i want to do context
switch within the timer ISR.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how many registers are pushed into the stack when running an ISR ?</title><link>https://community.arm.com/thread/51023?ContentTypeID=1</link><pubDate>Mon, 13 Aug 2007 07:31:05 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:bcaf977c-ed24-4ce7-bad7-b91bc7378cd9</guid><dc:creator>Christoph Franck</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;I want to change the return address in the stack when running
an ISR so that it returns to the specified address.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
This question seems to pop up at least once a month.&lt;/p&gt;

&lt;p&gt;
And the answer is always:&lt;/p&gt;

&lt;p&gt;
This is generally a &lt;b&gt;bad idea&lt;/b&gt;. And it is an especially bad
idea on the &lt;b&gt;&amp;#39;51 architecture&lt;/b&gt;. There are ways of accomplishing
what you are trying to do without resorting to manually messing with
the return address.&lt;/p&gt;

&lt;p&gt;
If you can describe why you think you need to mess with the
contents of the stack, then the people on this forum can certainly
point you in the right direction on how to do this with much, much
less headaches.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>