Re: [cc65] Moving the stack to a different segment?

From: Greg King <greg.king41verizon.net>
Date: 2012-03-12 20:13:52
From: "Joseph Rose"; on Tuesday, March 06, 2012; at 10:24 AM -0500

> I want to create new start-up configurations for a library for CC65;
> and, I want to move the stack to a different segment. I know that I
> simply could change the value written to the "sp" pointer in the
> zero-page; but, I'm sure that it is not enough. How do I prevent the
> stack from corrupting the data stored in the new segment?

The stack isn't put in a segment; it's put into a separate memory area.
That area isn't named; it's implied by two expressions.  The first one
is in the ld65 configuration file.  For example, "c64.cfg" has
"size = $C7F3 - __STACKSIZE__".  The second one is in the start-up code.
For example, "c64/crt0.s" has
"(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)".

If it were named explicitly (it _should_ be!),
then they would look like this:

HEADER: file=%O, define=yes, start=$0801, size=$000C;
STACK: file="", define=yes, start=$d000-__STACKSIZE__, size=__STACKSIZE__;
RAM: file=%O, define=yes, start=__HEADER_LAST__, size=__STACK_START__-__RAM_START__;

And, sp would be set to "(__STACK_START__ + __STACK_SIZE__)".

If you do want to put your stack into a segment, then you simply
assemble a big buffer, put a label at the end of it, and store that
label in sp.

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Mon Mar 12 20:14:36 2012

This archive was generated by hypermail 2.1.8 : 2012-03-12 20:14:40 CET