neilsf / xc-basic3

A BASIC cross compiler for MOS 6502-based machines
MIT License
44 stars 5 forks source link

[3.1] String and Function stack locations #221

Closed Diduz closed 1 year ago

Diduz commented 1 year ago

I was trying to understand where all the garbled characters came from in my C64 program, until I realized that there are string and functions stacks where I used to put my screen ram and custom fonts. :-P V.2.3 allowed the use of all the memory up to $CFFF, hence my mistake. Of course I could move screen ram and fonts somewhere else, but I would be forced to cut the game content. Unfortunately I'm working on a text adventure, which is a memory hungry genre... Is there a safe address limit not to be crossed, to avoid stumbling into the function stack? Is there a chance the stacks can be moved somewhere else? (I know, this is SO selfish). :-D

neilsf commented 1 year ago

Hi @Diduz Currently, on the C64, the string stack reserves $CF00-$CFFF and the function stack grows downwards from $CEFF. If you only use STATIC subs and functions, the function stack won't be used at all. To change the string stack location, you can change this line in the lib/ folder: https://github.com/neilsf/xc-basic3/blob/ee03ec15aa1dab5f06fa667336d3187799319a82/lib/core/stack/stack.asm#L6 Note that your changes may be lost if you later update XC=BASIC. I'll consider making this a configurable option in the future. Does this answer your question?

Diduz commented 1 year ago

Does this answer your question?

Yes, thanks. :-) I've to think this through.