--- story: E01-S05 owner: e01_memory_map status: done started: 2026-11-07 depends-on: [E01-S02, E01-S03, E01-S04] --- # E01-S05 Claim ## Intended change Freeze the compiler memory map from E01 evidence: common-RAM placement, a private compiler zero page via P0, bank-1 table space, and a fixed test mailbox. Provide `cfg/compiler.cfg`, `src/common/c128.inc`, `src/common/mailbox.inc`, and the production `src/compiler/mmu.s` (bank switching, KERNAL wrapper, NMI guard), then prove them with a linked skeleton in x128. ## File area - `cfg/compiler.cfg` - `src/common/c128.inc`, `src/common/mailbox.inc` - `src/compiler/mmu.s` - `tests/platform/map-skeleton.s` - `scripts/build-map-skeleton.ps1`, `scripts/verify-map-skeleton.ps1` - `docs/architecture.md` section 4, `docs/decisions.md` - `planning/claims/E01-S05.md` - generated files under `build/` ## Acceptance evidence - [x] `docs/architecture.md` lists verified regions and reservations (section 4.4; full table and evidence in `docs/memory-map.md`). - [x] `cfg/compiler.cfg` can link a capacity-checking skeleton (normal link passes; ZP, COMMON, MAIN, SWSTACK, and TABLES overflow builds are each rejected by ld65 in the expected memory area). - [x] `src/common/c128.inc` defines observed hardware/KERNAL constants, each annotated with the document holding its evidence. - [x] The test mailbox address and protocol are documented and exercised (`$1BF0`, `src/common/mailbox.inc`; x128 run reads `4E 38 01 A5 00 00 ...`). ## Coordination notes Absorbs the E01-S03 open NMI risk: the skeleton takes a CIA #2 timer NMI while bank 1 and the private zero page are active. ## Work log - Read from x128 ROM: `$FFFA` -> `$FF05` (SEI, push A/X/Y/CR, CR=0, `JMP ($0318)`); `$FF33` pops CR/Y/X/A and RTIs; `$FF17` IRQ path jumps via `$0314` into BASIC, which uses system zero page. `$1300-$1BFF` holds only the power-on fill pattern after boot. - First x128 run never touched the mailbox: `mmu.s` linked first, so `mmu_init` sat at the `SYS 7181` target. Added a `STARTUP` segment placed first and a build check that the entry label is at `$1C0D`. - Memory-area and segment `define` symbols collided (`__DISKBUF_SIZE__`); only the memory areas define symbols now. - A CIA #2 timer NMI taken in the bank-1 state with the private zero page returns cleanly through ROM `$FF05` -> `mmu_nmi_guard` -> `$FF33`, which closes the E01-S03 NMI risk. - Negative control: forcing P0L to `$00` in `mmu_bank0/1` gives mailbox FAIL code `$000F` (ZP, KCALL, BANK1, NMI). Source restored afterwards. - Found that the earlier branch switch/merge had rewritten all committed `newLang/` text files with CRLF (`core.autocrlf=true`), breaking the grammar validator. Added `newLang/** text=auto eol=lf` to `.gitattributes` and converted the 79 files back to LF; they match the committed blobs again. ## Completion - Tests run: `scripts/verify-map-skeleton.ps1` (includes five overflow builds), mutation run, `tests/grammar/validate.ps1`, `tests/disk/prepare-disk.tests.ps1`, `scripts/verify-minimal.ps1`, `scripts/verify-display-clock.ps1`, `scripts/verify-mmu-probe.ps1`, `scripts/verify-kernal-probe.ps1`. - Results: skeleton PASS with code `$0000`; one NMI under CR `$4E` / P0 `$1A` with sentinel `$C5` intact; screenshot shows both KCALL lines and `NOVA128 MAP SKELETON OK`; all earlier regressions pass, and the disk builder still produces SHA-256 `208EF297...`. - Files changed: `cfg/compiler.cfg`, `src/common/c128.inc`, `src/common/mailbox.inc`, `src/compiler/mmu.s`, `tests/platform/map-skeleton.s`, `scripts/build-map-skeleton.ps1`, `scripts/verify-map-skeleton.ps1`, `docs/memory-map.md`, `docs/architecture.md`, `docs/decisions.md` (D117), this claim, and the repository `.gitattributes`. - Remaining risks: generated-program map still open (E04); bank-1 block-copy routines not yet written (only byte peek/poke); RESTORE is ignored during compilation (documented in D117); IRQs stay masked, so long compiler phases freeze the jiffy clock and keyboard except during KERNAL calls; VICE-only evidence.