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

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2009-02-05 23:18:17
On Thu, Feb 05, 2009 at 12:39:15PM -0800, steve-cc65 wrote:
> I'm assuming this is some sort of CC65/C specific stack rather than a
> CPU register jsr/push/pop stack.

It's the stack used for function parameters and variables.

> If so, what is the right size or
> minimum size I should allocate for this?

That does highly depend on your program and programming style, there are no
simple rules. The stack is used for parameters and variables, so if you find
yourself writing code like

        void recursive (int num)
        {
            char buf[128];
            sprintf (Buf, "num is now %d\n", num);
            output (Buf);
            if (num > 0) {
                recursive (num-1);
            }
        }

        ...
        recursive (50);

be prepared to increase the default stack size.

> Please keep in mind that I am dealing with extreme legacy hardware which
> only has about $600 in total usable RAM!

Oliver has cited a few numbers for a real world program.

> What happens if I do not define the STACKSIZE symbol?

That depends on the platform and how the compiler is called. On some platforms
you *may* get a linker error if you don't define it. If you compile with
--check-stack, you will definitely get a linker error, since the stack
checking routines reference __STACK_SIZE__.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de
----------------------------------------------------------------------
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 23:21:17 2009

This archive was generated by hypermail 2.1.8 : 2009-02-05 23:21:19 CET