On 4/4/07, <b class="gmail_sendername">Richard</b> <<a href="mailto:richard-lists@imagecraft.com">richard-lists@imagecraft.com</a>> 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's "Y" or R28/R29 being used as the frame pointer, not RAMPY.</blockquote><div><br> Fair enough, I was saying RAMPY, but was thinking Y. 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. I was confused about the statement that it is "the most transparent use of data RAM." </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's an<br>IO register, e.g. you can'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. And LDS/STS take 2 clock cycles (assuming internal memory). Is there some other bottleneck? 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'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. I looked at the generated code and it does sync them up. But unfortunately, it has to disable interrupts when it does this. 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. 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>"To love for the sake of being loved is human; to love for the sake of loving is Angelic." -- Alphonse de Lamartine