aboutsummaryrefslogtreecommitdiff
path: root/docs/history/01-golf/notes.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/history/01-golf/notes.md')
-rw-r--r--docs/history/01-golf/notes.md10
1 files changed, 10 insertions, 0 deletions
diff --git a/docs/history/01-golf/notes.md b/docs/history/01-golf/notes.md
new file mode 100644
index 0000000..f8c8b5d
--- /dev/null
+++ b/docs/history/01-golf/notes.md
@@ -0,0 +1,10 @@
+# the golfed vm
+
+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 1
+
+> codegolf a tiny cpu vm in C89. the goal is to achieve the lowest character count possible. include an assembler as well (scored separately) and a hello world program (not scored, but elegance and simplicity is a bonus)
+> it must be capable of re-entrant code and a realistically workable instruction set.
+
+**summary:** a two-stack forth-style machine. the vm was 384 bytes: one ternary chain inside `while(o=m[p++])`, the top two stack items cached in `a` and `b`, the program loaded with `read(open(...))` so it needs no headers, and both stacks inside the 65536-word memory. it had 22 opcodes including div and mod, a two-word literal, and jump/call targets popped from the stack. the assembler was 348 bytes and two-pass, using `strcspn` instead of `strchr` so the implicit int return stays safe on 64-bit. hello world was a pointer loop over a string with a zero terminator. re-entrancy was shown with a recursive factorial plus a recursive decimal printer.