aboutsummaryrefslogtreecommitdiff
path: root/docs/history/05-hybrid/notes.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/history/05-hybrid/notes.md')
-rw-r--r--docs/history/05-hybrid/notes.md9
1 files changed, 9 insertions, 0 deletions
diff --git a/docs/history/05-hybrid/notes.md b/docs/history/05-hybrid/notes.md
new file mode 100644
index 0000000..e111cec
--- /dev/null
+++ b/docs/history/05-hybrid/notes.md
@@ -0,0 +1,9 @@
+# the assembler in assembly, and the hybrid compiler
+
+no code from this stage survives except where a code/ folder sits next to this file. these are the notes as they were written in the transcript.
+
+## message 5
+
+> can you write the assembler in assembly and pair the code with the assembly and the assembler so that it can re-wire itself at runtime? or maybe include an interp for self-modification, otherwise fns are exec'd native
+
+**summary:** both. `aslib.s` is the assembler written in vm assembly as a library (`a.src`, `a.dst`, `a.org`, `a.lab`, then `a.run c`), and with `asmain.s` it's a 568-word standalone assembler. it's byte-identical to the c assembler and reaches a fixpoint when assembling itself. this is also where the `:;comment` trick came from. the compiler became a hybrid. the image is split into basic blocks, each block counts how many of its words differ from the original image, and stores into code go through a slow path that updates the counters. clean blocks run native, while dirty blocks and anything past the image run in an interpreter compiled into the same binary, which hands control back to native code whenever it lands in a clean block. `cc -t` printed `[` and `]` at each switch. the demo rewired a function at runtime to point at freshly assembled code and then restored it.