A PIC C compiler cannot reasonably guarantee that it will not generate code that can overflow the stack. Return addresses get pushed onto the stack both in the context of base level code and interrupt level code. A stack overflow will occur if the total stack usage by both calling trees exceeds the stack space of the processor. It is not all that difficult to determine the maximal stack usage by either calling tree, however, under most circumstances it is not possible for the compiler to determine the maximal combined stack usage of both calling trees. -Mike -----Original Message----- From: Barry Gershenfeld [mailto:barry@zmicro.com] Sent: Tuesday, January 16, 2001 1:34 PM To: PICLIST@mitvma.mit.edu Subject: [PIC]:CCS C and stacks You guys seem to be saying that it's possible to write a C program that won't run on the PIC after it's compiled, because you may exceed the stack size. Is this true? I would expect the compiler to either be careful not to do this or to avoid using the hardware stack for conventional call/return at all. Especially on a chip with a 2-level stack! If all this is a real problem, then which operations use the stack? Just function calling? If I can figure out how to get a call tree out of my PCW compiler I'll probably be able to answer this myself. Barry -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu