Просмотр исходного кода

docs(compiler): close GENZ80 trigger + NATIVE module notes

Eric Streit 1 неделя назад
Родитель
Сommit
f53555f745
2 измененных файлов с 31 добавлено и 11 удалено
  1. 26 10
      src/compiler/GENZ80.md
  2. 5 1
      src/compiler/PASS1.MOD

+ 26 - 10
src/compiler/GENZ80.md

@@ -27,17 +27,22 @@ END;
 Failure mode is uniform with other overlays (`Loader.LoadError` →
 `ERROR: CANNOT LOAD OVERLAY`, delete partial output).
 
-## Trigger chain (partly open)
+## Trigger chain (CLOSED 2026-10-04, original media evidence)
 
-* Shell run menu sets `ComLine.execute` = 4 (bytecode) vs 5 (native Z80)
-  (`shell.txt` @1351, explicit comment in disassembly).
-* `CodeGen.InitCodeGenerator` reads `execute` (`checkOverflow := execute = 4`).
-* Setter of `Compiler.nativeCodeRequested=TRUE` NOT FOUND in any recovered
-  code: no `store COMPILER.word25` exists in `compiler/scanner/symtab/pass1/
-  statement/express/codegen/shell.txt` (only the FALSE init in `compiler.txt`
-  @07ec). Candidates: shell compile path (no COMPILER dependency though),
-  `Scanner.Compile` prologue (not in the decompiled body — which may itself
-  be incomplete), or a lost `%`-option branch. OPEN QUESTION for verification.
+* Shell Options menu has a `Native/2` toggle flipping bit 2 of the options
+  word at absolute `[0x348]` (persisted to M2.COM file offset 584; `%N`
+  command-line sets the same bit: `N-L=2` in `InitCompiler`).
+* `InitCompiler` computes `COMPILER.word2 := 2 IN scanOptions` (verified
+  byte-identical in `m2.ovr` @`0x53A0` and `compiler.txt` @`07ec`).
+* PASS1 body epilogue copies `COMPILER.word2` -> `COMPILER.word25`
+  (`compile.mcd` @file `0x1065`, `m2.ovr` PASS1 likewise). In our tree that
+  reads `rangeCheckEnabled -> nativeCodeRequested` (recorded on the
+  `InitPass1` stub in PASS1.MOD).
+* `Scanner.Compile` tests the flag (`m2.ovr` @`0x1D55`, matches our
+  SCANNER.MOD) and calls `Loader.Call("GENZ80")`.
+* (`ComLine.execute` = 4 bytecode vs 5 native is the parallel shell-run
+  knob; `CodeGen` reads it for overflow checks. Shipped M2.COM has Native
+  OFF by default.)
 
 ## Recovery status: binary absent
 
@@ -73,3 +78,14 @@ So there is nothing to decompile yet. Recovery plan:
 * Uses: `Scanner.*` (source/options), `Compiler.*` (predefs), `CodeGen.*`
   (opcodes/fixup helpers), `Files.*` (output).
 * Must NOT disturb `SymTab` heaps (they sit above the code window).
+
+## NATIVE module (found bundled in genz80.mcd)
+`genz80.mcd` holds TWO modules: NATIVE (base mem `0x19F1`, 52 procs) +
+INTELL (base `0x39EC`, the emitter). INTELL dep slot points at NATIVE
+(co-linked same file); NATIVE points back at INTELL. No `native.mcd` on
+disk, nothing NATIVE in `syslib.lib` — it ships bundled, not standalone.
+NATIVE is the MCode reader core: GETBYT/NEXTBY/NEXTWO/LOOKAH (bytecode
+fetch), ASSERT/FATAL/DPATCH/PATCH/SETLAB (labels), GEN1L2/PUSHIT/POPIT/
+STACKE/GENCAL (codegen callbacks), WRITEP/WRITEH/WRITET/WRITEA (writers),
+PLUS the driver + epilogue regions no group covered yet.
+Disassembly: `docs/compiler/disasm/native.txt` (4499 lines).

+ 5 - 1
src/compiler/PASS1.MOD

@@ -94,7 +94,11 @@ PROCEDURE TryParseDecl(tag: CARDINAL): BOOLEAN; FORWARD; (* proc29 *)
 PROCEDURE ParseImportScope; FORWARD; (* proc30 *)
 PROCEDURE CheckForwardResolved; FORWARD; (* proc36: body patched away *)
 PROCEDURE Pass1Main; FORWARD; (* @1027: no bytes *)
-PROCEDURE InitPass1; FORWARD; (* 4NAZBA @105b: no bytes *)
+PROCEDURE InitPass1; FORWARD; (* 4NAZBA @105b: no bytes in pass1.txt (file ends ~101a).
+   TRIGGER (original m2.ovr/PASS1 body epilogue): the init epilogue copies
+   COMPILER.word2 -> COMPILER.word25, i.e. rangeCheckEnabled ->
+   nativeCodeRequested. Chain: shell Native menu / %N -> bit 2 @[0x348] ->
+   scanOptions -> word2 -> (here) word25 -> Loader.Call("GENZ80"). *)
 (* SCANNER.proc24 discovery (group 1): 2-param length-prefix function *)
 PROCEDURE CappedStrLen(s: ADDRESS; maxLen: CARDINAL): CARDINAL; FORWARD;