fix: relieve code overflow that crashed string operations#145
Merged
Conversation
The resident (non-paged) code section had overflowed past $C000 into kernel-reserved I/O space by $95 bytes. This stranded StringTempWrite across the $C000 boundary, so any operation building a temporary string (concatenation, STR$, CHR$, substrings) executed I/O space as code and crashed. Programs using string concatenation — e.g. ashanghai.bas — crashed on their first concat. Move the boot-only DisplayBannerText routine (and its macros) to a slot 3 kernel module, called once at boot via the generated thunk. The banner string/build data stays resident and is read from the module. This frees ~230 bytes of resident code; the $C000 overflow is gone and string temporaries sit safely below the boundary. Verified in MAME: no overflow warning, banner renders correctly, a$="x"+"y" works, STR$/CHR$/LEFT$/MID$/RIGHT$ work, and ashanghai.bas loads all assets and runs. Signed-off-by: Matthias Brukner <mbrukner@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The resident (non-paged) code section had overflowed past
$C000into kernel-reserved I/O space by$95bytes — the standingBROKEN BUILDassembler warning. This strandedStringTempWriteacross the$C000boundary (its body ran into$C001+, which the F256 maps to I/O registers, not code). SinceStringTempWriteis called whenever a temporary string is built — string concatenation,STR$,CHR$, substrings — any such operation executed I/O space as code and crashed the machine.Programs relying on string concatenation crashed.
ashanghai.basdied on its first concat ("ashanghai/"+name$+".pal") during asset loading.Fix
Move the boot-only
DisplayBannerTextroutine (and its print macros) out of resident code into a slot 3 kernel module, called once at boot via the generated banking thunk. The banner's string/build data stays resident and is read from the module (resident code stays visible from slot 3). This frees ~230 bytes of resident code.Result: the
$C000overflow is gone, andStringTempWrite(now at$befc) sits safely below the boundary.Verification (MAME)
$C000overflow warning.a$="x"+"y"printsxy;STR$,CHR$,LEFT$,MID$,RIGHT$all work.ashanghai.basloads all assets and reaches the game.Note: this is a stopgap for the space pressure; the general fix is the paging rework.