Re: [cc65] STACKSIZE - What's the right size?

From: Oliver Schmidt <ol.sc1web.de>
Date: 2009-02-05 22:10:38
Hi Steve,

> I'm assuming this is some sort of CC65/C specific stack rather than a CPU
> register jsr/push/pop stack.

Yes.

> If so, what is the right size or minimum size
> I should allocate for this?  If I have simple functions that do not pass a
> lot of parameters can this be much, much smaller?

Yes.

If you have some emulator with debugger it should be quite easy to
determine the stacksize actually needed by a certain program by
setting the stack to some pattern at program start and check until
which point the pattern is still present at program exit.

Alternatively you can have the program determine its stacksize itself.
See here for a quick&dirty but nevertheless functional example using
an atexit() handler:

http://contiki.cvs.sourceforge.net/viewvc/*checkout*/contiki/contiki-apple2/main.c

Although my last CVS log for the corresponding linker config file
probably isn't perfectly self-explanatory ;-) it might be interesting
nevertheless:

==========
Reduced the stacksize to 256 bytes. Measurements have shown that the
actual stack usage seems to be less than 100 bytes but that wouldn't
allow for any additional scenario.

If we should ever come to the point where 128 bytes are missing than
further stack size reduction should be considered !
==========

Best, Oliver
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Thu Feb 5 22:10:44 2009

This archive was generated by hypermail 2.1.8 : 2009-02-05 22:10:47 CET