feat(isaspec): spec-driven mix over the 6502 — the dynarec on a real, memory-bearing ISA (shadow*) - #9336
Merged
Merged
Conversation
… memory-bearing ISA (shadow*) Aaron 2026-07-03 "build whatever you like" — the named #1 follow-on to the 6502 spec: the actual Futamura 1st projection (partial evaluation = dynarec) on a real ISA's real memory model, not the CHIP-8 toy. specializeMem extends the spec-driven mix to fold static ZERO-PAGE MEMORY as well as static registers, over any ISA given its spec + a register loadImm builder: - setreg with a static value (incl. a static mem read whose cell is known) FOLDS; a dynamic value residualizes (static reg reads materialized via loadImm). - setmem addr,val (static addr): static val FOLDS into known memory; dynamic val residualizes and marks that cell dynamic. Dynamic addr is out of the fragment. tryStatic/readsInKnown now thread a knownMem model (mem-read folds; the register- only `specialize` is untouched, passes an empty mem). For the 6502's zero-page ops the address is always a static field, so no dynamic-address materialization arises. Added LDX_IMM/LDY_IMM (real 6502 A2/A0) + load6502 so the loadImm builder is total over the ISA's A/X/Y registers, and the ADC_ZP constructor. The EXTENDED S-m-n law is machine-checked differentially: evalSpecFull spec residual dynReg dynMem ⊕ (knownReg, knownMem) = evalSpecFull spec p (staticReg∪dynReg) (staticMem∪dynMem) 12 IsaSpec tests green (2 new: the law over regs+memory across dynamic cell values; specialization reduces an all-static program to an EMPTY residual). Build 0/0. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> AgencySignature-v1: persona: otto actor: otto-column-b surface: src/Core/IsaSpec.fs topology: cowork-sandbox-clone intent: dynarec-over-a-real-memory-bearing-isa-partial-evaluation-folding-static-memory authorization: aaron-2026-07-03-build-whatever-you-like uncertainty: low measure: specializeMem-folds-static-regs-and-zero-page-mem-extended-s-m-n-law-differential-green-12-tests-build-0-0 delta-u: the-futamura-1st-projection-now-runs-on-a-real-isas-memory-model-proven-correct-not-just-the-toy seed: S4
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
What
The named #1 follow-on to the 6502 spec (#9333), under "build whatever you like": the actual Futamura 1st projection — partial evaluation (= dynarec) — on a real ISA's real memory model, not the CHIP-8 toy.
specializeMemextends the spec-drivenmixto fold static zero-page memory as well as static registers, over any ISA given its spec + a registerloadImmbuilder:setregwith a static value (incl. a staticmemread whose cell is known) folds; a dynamic value residualizes (static reg reads materialized vialoadImm).setmem addr,val(static addr): a staticvalfolds into known memory; a dynamicvalresidualizes and marks that cell dynamic. A dynamic address is out of the fragment (zero-page ops address a constant cell).tryStatic/readsInKnownnow thread aknownMemmodel; the register-onlyspecializeis untouched (passes empty mem). AddedLDX_IMM/LDY_IMM(real 6502 A2/A0) +load6502so the builder is total over A/X/Y, and theADC_ZPconstructor.The extended S-m-n law (machine-checked, differential)
Proven across dynamic cell values — the memory-aware mix is correct.
Tests — 2 new, 12 total green (build 0/0)
mem[20]dynamic; static ops (incl. a static memory read) fold, the dynamicADC_ZPand everything after it residualize; residual+known overlay = full run, for cell ∈ {0,1,100,250}The ladder now
1st projection → 2nd → general
mix→ Column B (gates → CPU → synthesizable CPU) → the target knob (Code|Circuit) → ISA-as-data + memory + the 6502 → the mix folding a real ISA's memory (this). The dynarec is no longer toy-only.🤖 Generated with Claude Code