On Thu, 23 Oct 2008, Tamas Rudnai wrote: > >> I cited two examples from the PIC world, C18 and C30, > >> that I happen to know create stack frames. > > > > They cerate stack frames for empty (no locals, no code) functions? > > If there is no locals and parameters then C18 will not create a stack frame. > I did not have a look at the C30 yet. > > > None of the 12/14-bit core C compilers that I know create stack frames > > (or maybe they will, but only if pressed to do so). One might argue that > > such compilers are not proper C compilers, because they use a > > stack-stack memory allocation that does not permit recursion. > > It is not only the recursion, but also reentability - like a function is > execution when an interrupt occurs where the ISR calls that function as > well. Or if there is an RTOS - how would it deal with the concurrent > threads? You build multi-tasking into the language and not try to implement it as an after thought through libraries. > > BTW: How would you resolve the increased RAM which should occur when only > static variables are in use? (even functions that are rarely called > statically occupies RAM). Is there any compiler technique to statically > analyse the program flow and use overlapped memory usage for these local > variables? Yes, a compiler can analyse the way functions interact and produce a map of which RAM locations must be preserved during which function calls. This allows areas of RAM to be statically assigned during compile time to multiple functions (functions which cannot be active at the same time). The effect is like modeling the runtime stack by predicting where the stack pointer will be when function X is called from function Y and then hard coding the location of the automatic local variables relative to the predicted top of stack. This type of stack is often refered to as a static stack because it doesn't actually change at run time. The XCSB compiler (which is not a C compiler) supports multitasking, builds static stacks for each thread and produces task (and ISR) safe code. Regards Sergio Masci -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist