On 4/4/07, <b class="gmail_sendername">Richard</b> &lt;<a href="mailto:richard-lists@imagecraft.com">richard-lists@imagecraft.com</a>&gt; wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
First, it&#39;s &quot;Y&quot; or R28/R29 being used as the frame pointer, not RAMPY.</blockquote><div><br>&nbsp;Fair enough, I was saying RAMPY, but was thinking Y.&nbsp; That is, using an index register as a frame pointer.<br></div>
<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Second, the primary reason for having 2 stacks is code efficiency. The CALL</blockquote>
<div><br>Ok, so it is about efficiency.&nbsp; I was confused about the statement that it is &quot;the most transparent use of data RAM.&quot;&nbsp;</div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
stack is architecture in the ISA (Instruction set architecture) but it&#39;s an<br>IO register, e.g. you can&#39;t access anything off the stack frame without the<br>expensive copying to and fro from the IO SP. This is very expensive. I
</blockquote><div><br>Looking at the ISA documentation, IN/OUT instructions take 1 clock cycle.&nbsp; And LDS/STS take 2 clock cycles (assuming internal memory).&nbsp; Is there some other bottleneck?&nbsp; I think I know what it is--see below.
<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">believe GCC maintains a single stack by sync&#39;ing up the software and<br>hardware stack at function points (not 100% sure), but I have not heard
<br>that being more or even as efficient as using two stacks.<br></blockquote></div><br>That is what AVR GCC does.&nbsp; I looked at the generated code and it does sync them up.&nbsp; But unfortunately, it has to disable interrupts when it does this.&nbsp; That I can see is an advantage to having a separate hw and sw stack (or as a disadvantage to having a stack pointer that cannot be written atomically).
<br><br>Thanks for the clarification.&nbsp; You gave me the nudge to look at what AVR GCC does and it shows why 2 stacks are better than 1!<br><br>Thanks,<br>Pete<br>--<br>&quot;To love for the sake of being loved is human;&nbsp;&nbsp;to love for the sake of loving is Angelic.&quot;&nbsp;&nbsp;-- Alphonse de Lamartine