aboutsummaryrefslogtreecommitdiff
path: root/docs/history/04-darwin-compiler/notes.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/history/04-darwin-compiler/notes.md')
-rw-r--r--docs/history/04-darwin-compiler/notes.md9
1 files changed, 9 insertions, 0 deletions
diff --git a/docs/history/04-darwin-compiler/notes.md b/docs/history/04-darwin-compiler/notes.md
new file mode 100644
index 0000000..b42a9c8
--- /dev/null
+++ b/docs/history/04-darwin-compiler/notes.md
@@ -0,0 +1,9 @@
+# an ahead-of-time compiler to darwin arm64
+
+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 4
+
+> now let's move in stages. write a compiler that takes this assembler's code and converts it into darwin arm
+
+**summary:** an ungolfed c89 compiler from vm assembly to darwin arm64 assembly. every word got its own label, the image was emitted as an addressable data array, x19/x20/x21 held the memory base and the two stack pointers, and computed jumps went through a table of offsets. a literal followed by a jump became a direct branch. `Q` and `G` went through `sxtb`, since char is signed on apple arm64, and `J` was read with `ldrb`. it was verified by assembling with llvm-mc for darwin, then rewriting to linux with sed and running under qemu, where it matched the vm byte for byte. this version couldn't handle self-modifying code.