Skip to content

fix: relieve code overflow that crashed string operations#145

Merged
mbrukner merged 2 commits into
mainfrom
fix/code-overflow-relief
Jul 9, 2026
Merged

fix: relieve code overflow that crashed string operations#145
mbrukner merged 2 commits into
mainfrom
fix/code-overflow-relief

Conversation

@mbrukner

@mbrukner mbrukner commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Problem

The resident (non-paged) code section had overflowed past $C000 into kernel-reserved I/O space by $95 bytes — the standing BROKEN BUILD assembler warning. This stranded StringTempWrite across the $C000 boundary (its body ran into $C001+, which the F256 maps to I/O registers, not code). Since StringTempWrite is 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.bas died on its first concat ("ashanghai/"+name$+".pal") during asset loading.

Fix

Move the boot-only DisplayBannerText routine (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 $C000 overflow is gone, and StringTempWrite (now at $befc) sits safely below the boundary.

Verification (MAME)

  • Build shows no $C000 overflow warning.
  • Boot banner renders correctly (machine name, info, kernel, build version/timestamp).
  • a$="x"+"y" prints xy; STR$, CHR$, LEFT$, MID$, RIGHT$ all work.
  • ashanghai.bas loads all assets and reaches the game.

Note: this is a stopgap for the space pressure; the general fix is the paging rework.

mbrukner added 2 commits July 10, 2026 00:14
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>
@mbrukner
mbrukner merged commit 31ad261 into main Jul 9, 2026
1 check passed
@mbrukner
mbrukner deleted the fix/code-overflow-relief branch July 9, 2026 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant