Add the generated-program container and writer. src/compiler/output.s accepts
a source base name, writes a PRG with a valid load-address header and ordered
sections, records each section's start/size plus the entry point in a MAP file,
and emits the fixed BASIC 7 stub and startup path from
src/runtime/startup.s. The generated program initializes the test mailbox,
reports pass, and returns cleanly to BASIC.
An existing NAME.PRG or NAME.MAP is refused with the new disk diagnostic
E202 instead of being overwritten. Outputs created by the current run are
scratched if emission fails or the caller aborts, so no partial final file is
left behind.
src/compiler/output.s (new), src/runtime/startup.s (new)src/common/formats.inc (new), src/common/diagcat.inc, docs/diagnostics.mdtests/codegen/output-test.sscripts/build-output-test.ps1, scripts/verify-output-test.ps1docs/decisions.md, docs/architecture.md, docs/memory-map.mdplanning/claims/E04-S01.mdbuild/generate.prg is 133 bytes, starts with 01 1C, contains the
verified 12-byte 10 SYS 7181 stub at $1C01, 74 startup bytes at $1C0D,
zero padding through $1C7F, and DE AD BE EF at $1C80.$03, status $A5, code 0, empty data,
and returns to BASIC.collide.prg/collide.map fixtures cause
OUT_ERR_EXISTS; both files remain byte-for-byte unchanged because nothing
is opened before the check.order.prg
section-order failure and the abort.prg partial-section run both call
out_abort; neither PRG nor MAP exists afterwards.generate.map is the
exact CR-terminated sequence NOVA128 MAP 1, ENTRY 1C0D,
SECTION STUB 1C01 000C, SECTION START 1C0D 004A,
SECTION PAD 1C80 0004.done; no other claim overlapped this area.$4000 where BASIC's mapping
exposes RAM.output.s returns OUT_ERR_EXISTS; E202 is in the stable catalog for the
compiler shell (a later story) to report. No shell integration was invented
here.diskio.s wrappers; no module
except mmu.s touches the MMU.out_rec_ptr was in BSS; 6502 (ptr),y requires
zero page. Moved it to ZEROPAGE.out_begin and out_write_map needed short-branch/jmp
trampolines.OUT_ERR_ORDER: the load-address header had advanced
out_current to $1C03, so the $1C01 STUB section looked backward. The
writer now rewinds to out_load after the header.01: out_byte loaded the section
flag into A before calling out_put. It now saves the byte first.out_startup had ended its
section, producing OUT_ERR_STATE; it now opens an explicit X section and
writes $AA before aborting.scripts/build-output-test.ps1scripts/verify-output-test.ps1 -Port 6530 -RunPort 6531scripts/build-diag-test.ps1 -UpdateDocsscripts/verify-diag-test.ps1 -Port 6530scripts/verify-parser-test.ps1 -Port 6530git diff --check$A7.src/compiler/output.s, src/runtime/startup.s,
src/common/formats.inc, src/common/diagcat.inc, docs/diagnostics.md,
tests/codegen/output-test.s, scripts/build-output-test.ps1,
scripts/verify-output-test.ps1, docs/decisions.md,
docs/architecture.md, docs/memory-map.md, this claim.$3FFF are E04-S02 work; out_load is
caller-controlled rather than validated against the fixed container.Powered by TurnKey Linux.