summary refs log tree commit diff
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2026-04-20 23:41:19 -0700
committerIrene Knapp <ireneista@irenes.space>2026-04-20 23:41:19 -0700
commite49e80fd5a261a6f16dc38b23761e7834106f39c (patch)
tree5263bebc18ac31caf527c7e062757cfc0418b225
parenta8d57a352e0f615fbc475159491d93e4f5c15673 (diff)
it can interpret integer literals now!!!! yay
only decimal tho

Force-Push: yes
Change-Id: I79cfbdee7beb927855e1b32869ac760754af062d
-rw-r--r--quine.asm188
1 files changed, 155 insertions, 33 deletions
diff --git a/quine.asm b/quine.asm
index 7ff7cc0..908031d 100644
--- a/quine.asm
+++ b/quine.asm
@@ -6297,7 +6297,7 @@ cold_start:
   dq litstring, "@", early_find, entry_to_execution_token, early_comma
   dq litstring, "swap", early_find, entry_to_execution_token, early_comma
   dq litstring, "3unroll", early_find, entry_to_execution_token, early_comma
-  dq litstring, "eq", early_find, entry_to_execution_token, early_comma
+  dq litstring, "=", early_find, entry_to_execution_token, early_comma
   dq litstring, "0branch", early_find, entry_to_execution_token, early_comma
   dq lit, 5*8, early_comma
 
@@ -6331,7 +6331,7 @@ cold_start:
   dq litstring, "buffer-physical-end", early_find, entry_to_execution_token
   dq early_comma
   dq litstring, "@", early_find, entry_to_execution_token, early_comma
-  dq litstring, "eq", early_find, entry_to_execution_token, early_comma
+  dq litstring, "=", early_find, entry_to_execution_token, early_comma
   dq litstring, "0branch", early_find, entry_to_execution_token, early_comma
   dq lit, 13*8, early_comma
 
@@ -6347,7 +6347,7 @@ cold_start:
   dq litstring, "buffer-logical-end", early_find, entry_to_execution_token
   dq early_comma
   dq litstring, "@", early_find, entry_to_execution_token, early_comma
-  dq litstring, "ne", early_find, entry_to_execution_token, early_comma
+  dq litstring, "!=", early_find, entry_to_execution_token, early_comma
   dq litstring, "0branch", early_find, entry_to_execution_token, early_comma
   dq lit, 7*8, early_comma
 
@@ -6377,7 +6377,7 @@ cold_start:
   dq litstring, "dup", early_find, entry_to_execution_token, early_comma
   dq litstring, "lit", early_find, entry_to_execution_token, early_comma
   dq lit, 0x20, early_comma
-  dq litstring, "eq", early_find, entry_to_execution_token, early_comma
+  dq litstring, "=", early_find, entry_to_execution_token, early_comma
   dq litstring, "0branch", early_find, entry_to_execution_token, early_comma
   dq lit, 5*8, early_comma
   dq litstring, "drop", early_find, entry_to_execution_token, early_comma
@@ -6388,7 +6388,7 @@ cold_start:
   dq litstring, "dup", early_find, entry_to_execution_token, early_comma
   dq litstring, "lit", early_find, entry_to_execution_token, early_comma
   dq lit, 0x09, early_comma
-  dq litstring, "eq", early_find, entry_to_execution_token, early_comma
+  dq litstring, "=", early_find, entry_to_execution_token, early_comma
   dq litstring, "0branch", early_find, entry_to_execution_token, early_comma
   dq lit, 5*8, early_comma
   dq litstring, "drop", early_find, entry_to_execution_token, early_comma
@@ -6399,7 +6399,7 @@ cold_start:
   dq litstring, "dup", early_find, entry_to_execution_token, early_comma
   dq litstring, "lit", early_find, entry_to_execution_token, early_comma
   dq lit, 0x0a, early_comma
-  dq litstring, "eq", early_find, entry_to_execution_token, early_comma
+  dq litstring, "=", early_find, entry_to_execution_token, early_comma
   dq litstring, "0branch", early_find, entry_to_execution_token, early_comma
   dq lit, 5*8, early_comma
   dq litstring, "drop", early_find, entry_to_execution_token, early_comma
@@ -6410,7 +6410,7 @@ cold_start:
   dq litstring, "dup", early_find, entry_to_execution_token, early_comma
   dq litstring, "lit", early_find, entry_to_execution_token, early_comma
   dq lit, 0x0b, early_comma
-  dq litstring, "eq", early_find, entry_to_execution_token, early_comma
+  dq litstring, "=", early_find, entry_to_execution_token, early_comma
   dq litstring, "0branch", early_find, entry_to_execution_token, early_comma
   dq lit, 5*8, early_comma
   dq litstring, "drop", early_find, entry_to_execution_token, early_comma
@@ -6421,7 +6421,7 @@ cold_start:
   dq litstring, "dup", early_find, entry_to_execution_token, early_comma
   dq litstring, "lit", early_find, entry_to_execution_token, early_comma
   dq lit, 0x0c, early_comma
-  dq litstring, "eq", early_find, entry_to_execution_token, early_comma
+  dq litstring, "=", early_find, entry_to_execution_token, early_comma
   dq litstring, "0branch", early_find, entry_to_execution_token, early_comma
   dq lit, 5*8, early_comma
   dq litstring, "drop", early_find, entry_to_execution_token, early_comma
@@ -6432,7 +6432,7 @@ cold_start:
   dq litstring, "dup", early_find, entry_to_execution_token, early_comma
   dq litstring, "lit", early_find, entry_to_execution_token, early_comma
   dq lit, 0x0d, early_comma
-  dq litstring, "eq", early_find, entry_to_execution_token, early_comma
+  dq litstring, "=", early_find, entry_to_execution_token, early_comma
   dq litstring, "0branch", early_find, entry_to_execution_token, early_comma
   dq lit, 5*8, early_comma
   dq litstring, "drop", early_find, entry_to_execution_token, early_comma
@@ -6519,7 +6519,7 @@ cold_start:
   dq litstring, "and", early_find, entry_to_execution_token, early_comma
   dq litstring, "lit", early_find, entry_to_execution_token, early_comma
   dq lit, 0, early_comma
-  dq litstring, "eq", early_find, entry_to_execution_token, early_comma
+  dq litstring, "=", early_find, entry_to_execution_token, early_comma
   dq litstring, "0branch", early_find, entry_to_execution_token, early_comma
   dq lit, 5*8, early_comma
   dq litstring, "3roll", early_find, entry_to_execution_token, early_comma
@@ -6537,7 +6537,7 @@ cold_start:
   dq litstring, "and", early_find, entry_to_execution_token, early_comma
   dq litstring, "lit", early_find, entry_to_execution_token, early_comma
   dq lit, 0, early_comma
-  dq litstring, "eq", early_find, entry_to_execution_token, early_comma
+  dq litstring, "=", early_find, entry_to_execution_token, early_comma
   dq litstring, "0branch", early_find, entry_to_execution_token, early_comma
   dq lit, 8*8, early_comma
   dq litstring, "lit", early_find, entry_to_execution_token, early_comma
@@ -6558,7 +6558,7 @@ cold_start:
   dq litstring, "and", early_find, entry_to_execution_token, early_comma
   dq litstring, "lit", early_find, entry_to_execution_token, early_comma
   dq lit, 0, early_comma
-  dq litstring, "eq", early_find, entry_to_execution_token, early_comma
+  dq litstring, "=", early_find, entry_to_execution_token, early_comma
   dq litstring, "0branch", early_find, entry_to_execution_token, early_comma
   dq lit, 8*8, early_comma
   dq litstring, "lit", early_find, entry_to_execution_token, early_comma
@@ -6579,7 +6579,7 @@ cold_start:
   dq litstring, "and", early_find, entry_to_execution_token, early_comma
   dq litstring, "lit", early_find, entry_to_execution_token, early_comma
   dq lit, 0, early_comma
-  dq litstring, "eq", early_find, entry_to_execution_token, early_comma
+  dq litstring, "=", early_find, entry_to_execution_token, early_comma
   dq litstring, "0branch", early_find, entry_to_execution_token, early_comma
   dq lit, 8*8, early_comma
   dq litstring, "lit", early_find, entry_to_execution_token, early_comma
@@ -6600,7 +6600,7 @@ cold_start:
   dq litstring, "and", early_find, entry_to_execution_token, early_comma
   dq litstring, "lit", early_find, entry_to_execution_token, early_comma
   dq lit, 0, early_comma
-  dq litstring, "eq", early_find, entry_to_execution_token, early_comma
+  dq litstring, "=", early_find, entry_to_execution_token, early_comma
   dq litstring, "0branch", early_find, entry_to_execution_token, early_comma
   dq lit, 8*8, early_comma
   dq litstring, "lit", early_find, entry_to_execution_token, early_comma
@@ -6621,7 +6621,7 @@ cold_start:
   dq litstring, "and", early_find, entry_to_execution_token, early_comma
   dq litstring, "lit", early_find, entry_to_execution_token, early_comma
   dq lit, 0, early_comma
-  dq litstring, "eq", early_find, entry_to_execution_token, early_comma
+  dq litstring, "=", early_find, entry_to_execution_token, early_comma
   dq litstring, "0branch", early_find, entry_to_execution_token, early_comma
   dq lit, 8*8, early_comma
   dq litstring, "lit", early_find, entry_to_execution_token, early_comma
@@ -6642,7 +6642,7 @@ cold_start:
   dq litstring, "and", early_find, entry_to_execution_token, early_comma
   dq litstring, "lit", early_find, entry_to_execution_token, early_comma
   dq lit, 0, early_comma
-  dq litstring, "eq", early_find, entry_to_execution_token, early_comma
+  dq litstring, "=", early_find, entry_to_execution_token, early_comma
   dq litstring, "0branch", early_find, entry_to_execution_token, early_comma
   dq lit, 8*8, early_comma
   dq litstring, "lit", early_find, entry_to_execution_token, early_comma
@@ -6688,7 +6688,7 @@ cold_start:
   dq litstring, "dup", early_find, entry_to_execution_token, early_comma
   dq litstring, "lit", early_find, entry_to_execution_token, early_comma
   dq lit, 0, early_comma
-  dq litstring, "eq", early_find, entry_to_execution_token, early_comma
+  dq litstring, "=", early_find, entry_to_execution_token, early_comma
   dq litstring, "0branch", early_find, entry_to_execution_token, early_comma
   dq lit, 6*8, early_comma
   dq litstring, "drop", early_find, entry_to_execution_token, early_comma
@@ -6707,7 +6707,7 @@ cold_start:
   dq early_comma
   dq litstring, "lit", early_find, entry_to_execution_token, early_comma
   dq lit, 0, early_comma
-  dq litstring, "eq", early_find, entry_to_execution_token, early_comma
+  dq litstring, "=", early_find, entry_to_execution_token, early_comma
   dq litstring, "0branch", early_find, entry_to_execution_token, early_comma
   dq lit, 7*8, early_comma
   dq litstring, "dup", early_find, entry_to_execution_token, early_comma
@@ -6731,14 +6731,115 @@ cold_start:
   dq early_here, fetch, lit, 8, packalign, early_here_store
 
 
+  ; In:
+  ;   string pointer
+  ; Out:
+  ;   result (if successful)
+  ;   error indicator (zero indicates success)
+  dq litstring, "read-decimal-unsigned", early_create, early_docol_codeword
+
+  ; If the first byte is null, this is an error
+  dq litstring, "unpack8", early_find, entry_to_execution_token, early_comma
+  dq litstring, "dup", early_find, entry_to_execution_token, early_comma
+  dq litstring, "lit", early_find, entry_to_execution_token, early_comma
+  dq lit, 0, early_comma
+  dq litstring, "=", early_find, entry_to_execution_token, early_comma
+  dq litstring, "0branch", early_find, entry_to_execution_token, early_comma
+  dq lit, 6*8, early_comma
+  dq litstring, "drop", early_find, entry_to_execution_token, early_comma
+  dq litstring, "drop", early_find, entry_to_execution_token, early_comma
+  dq litstring, "lit", early_find, entry_to_execution_token, early_comma
+  dq lit, 1, early_comma
+  dq litstring, "exit", early_find, entry_to_execution_token, early_comma
+
+  dq litstring, "lit", early_find, entry_to_execution_token, early_comma
+  dq lit, "0", early_comma
+  dq litstring, "-", early_find, entry_to_execution_token, early_comma
+  dq litstring, "swap", early_find, entry_to_execution_token, early_comma
+  ; (result so far, current point in string)
+
+  ; Start of the loop.
+  dq litstring, "unpack8", early_find, entry_to_execution_token, early_comma
+  dq litstring, "dup", early_find, entry_to_execution_token, early_comma
+  dq litstring, "lit", early_find, entry_to_execution_token, early_comma
+  dq lit, 0, early_comma
+  dq litstring, "=", early_find, entry_to_execution_token, early_comma
+  dq litstring, "0branch", early_find, entry_to_execution_token, early_comma
+  dq lit, 6*8, early_comma
+
+  ; A null after the first character is valid, and indicates we're done.
+  dq litstring, "drop", early_find, entry_to_execution_token, early_comma
+  dq litstring, "drop", early_find, entry_to_execution_token, early_comma
+  dq litstring, "lit", early_find, entry_to_execution_token, early_comma
+  dq lit, 0, early_comma
+  dq litstring, "exit", early_find, entry_to_execution_token, early_comma
+
+  ; (result so far, current point in string, latest byte)
+  dq litstring, "lit", early_find, entry_to_execution_token, early_comma
+  dq lit, "0", early_comma
+  dq litstring, "-", early_find, entry_to_execution_token, early_comma
+  dq litstring, "3roll", early_find, entry_to_execution_token, early_comma
+  dq litstring, "lit", early_find, entry_to_execution_token, early_comma
+  dq lit, 10, early_comma
+  dq litstring, "*", early_find, entry_to_execution_token, early_comma
+  dq litstring, "+", early_find, entry_to_execution_token, early_comma
+  dq litstring, "swap", early_find, entry_to_execution_token, early_comma
+  dq litstring, "branch", early_find, entry_to_execution_token, early_comma
+  dq lit, -22*8, early_comma
+
+  dq early_here, fetch, lit, 8, packalign, early_here_store
+
+  dq litstring, "read-decimal", early_create, early_docol_codeword
+  dq litstring, "dup", early_find, entry_to_execution_token, early_comma
+  dq litstring, "unpack8", early_find, entry_to_execution_token, early_comma
+  dq litstring, "lit", early_find, entry_to_execution_token, early_comma
+  dq lit, "-", early_comma
+  dq litstring, "!=", early_find, entry_to_execution_token, early_comma
+  dq litstring, "0branch", early_find, entry_to_execution_token, early_comma
+  dq lit, 4*8, early_comma
+
+  ; This is the case where it's non-negative.
+  ; (original string pointer, advanced string pointer)
+  dq litstring, "drop", early_find, entry_to_execution_token, early_comma
+  dq litstring, "read-decimal-unsigned", early_find, entry_to_execution_token
+  dq early_comma
+  dq litstring, "exit", early_find, entry_to_execution_token, early_comma
+
+  ; This is the case where it's negative.
+  ; (original string pointer, advanced string pointer)
+  dq litstring, "swap", early_find, entry_to_execution_token, early_comma
+  dq litstring, "drop", early_find, entry_to_execution_token, early_comma
+  dq litstring, "read-decimal-unsigned", early_find, entry_to_execution_token
+  dq early_comma
+  ; (result maybe, exit code)
+  dq litstring, "dup", early_find, entry_to_execution_token, early_comma
+  dq litstring, "0branch", early_find, entry_to_execution_token, early_comma
+  dq lit, 2*8, early_comma
+
+  ; Failure
+  ; (non-zero exit code)
+  dq litstring, "exit", early_find, entry_to_execution_token, early_comma
+
+  ; Success
+  ; (result, zero exit code)
+  dq litstring, "swap", early_find, entry_to_execution_token, early_comma
+  dq litstring, "lit", early_find, entry_to_execution_token, early_comma
+  dq lit, -1, early_comma
+  dq litstring, "*", early_find, entry_to_execution_token, early_comma
+  dq litstring, "swap", early_find, entry_to_execution_token, early_comma
+  dq litstring, "exit", early_find, entry_to_execution_token, early_comma
+  dq early_here, fetch, lit, 8, packalign, early_here_store
+
+
   dq litstring, "interpret", early_create, early_docol_codeword
+  ; Start of the loop.
   dq litstring, "word", early_find, entry_to_execution_token, early_comma
 
   ; If no word was returned, exit.
   dq litstring, "dup", early_find, entry_to_execution_token, early_comma
   dq litstring, "lit", early_find, entry_to_execution_token, early_comma
   dq lit, 0, early_comma
-  dq litstring, "eq", early_find, entry_to_execution_token, early_comma
+  dq litstring, "=", early_find, entry_to_execution_token, early_comma
   dq litstring, "0branch", early_find, entry_to_execution_token, early_comma
   dq lit, 3*8, early_comma
   dq litstring, "drop", early_find, entry_to_execution_token, early_comma
@@ -6747,21 +6848,13 @@ cold_start:
   dq litstring, "dup", early_find, entry_to_execution_token, early_comma
   dq litstring, "find", early_find, entry_to_execution_token, early_comma
 
-  ; If the word isn't in the dictionary, also exit.
+  ; Check whether the word was found in the dictionary.
   dq litstring, "dup", early_find, entry_to_execution_token, early_comma
   dq litstring, "lit", early_find, entry_to_execution_token, early_comma
   dq lit, 0, early_comma
-  dq litstring, "eq", early_find, entry_to_execution_token, early_comma
+  dq litstring, "!=", early_find, entry_to_execution_token, early_comma
   dq litstring, "0branch", early_find, entry_to_execution_token, early_comma
-  dq lit, 8*8, early_comma
-  dq litstring, "drop", early_find, entry_to_execution_token, early_comma
-  dq litstring, "stack-deallocate-string-accumulator", early_find
-  dq entry_to_execution_token, early_comma
-  dq litstring, "litstring", early_find, entry_to_execution_token, early_comma
-  dq lit, "No such ", early_comma, lit, "word.", early_comma
-  dq litstring, "emitstring", early_find, entry_to_execution_token
-  dq early_comma
-  dq litstring, "exit", early_find, entry_to_execution_token, early_comma
+  dq lit, 6*8, early_comma
 
   ; If the word is in the dictionary, run it.
   dq litstring, "stack-deallocate-string-accumulator-with-result", early_find
@@ -6769,10 +6862,39 @@ cold_start:
   dq litstring, "entry-to-execution-token", 0, early_find
   dq entry_to_execution_token, early_comma
   dq litstring, "execute", early_find, entry_to_execution_token, early_comma
+  dq litstring, "branch", early_find, entry_to_execution_token, early_comma
+  ; o/~ Like a whirlpool and it never ends. o/~
+  dq lit, -21*8, early_comma
+
+  ; If it's not in the dictionary, check whether it's a decimal number.
+  dq litstring, "drop", early_find, entry_to_execution_token, early_comma
+  ; (string contents..., string pointer)
+  dq litstring, "dup", early_find, entry_to_execution_token, early_comma
+  dq litstring, "read-decimal", early_find, entry_to_execution_token
+  dq early_comma
+  dq litstring, "lit", early_find, entry_to_execution_token, early_comma
+  dq lit, 0, early_comma
+  dq litstring, "=", early_find, entry_to_execution_token, early_comma
+  dq litstring, "0branch", early_find, entry_to_execution_token, early_comma
+  dq lit, 4*8, early_comma
 
-  ; Like a whirlpool and it never ends.
+  ; It's a number; push it to the stack. Or at least, that's what the code
+  ; we're interpreting will see. Really it's already on the stack, just clean
+  ; everything else up and leave it there.
+  dq litstring, "stack-deallocate-string-accumulator-with-result", early_find
+  dq entry_to_execution_token, early_comma
   dq litstring, "branch", early_find, entry_to_execution_token, early_comma
-  dq lit, -28*8, early_comma
+  ; o/~ Like a whirlpool and it never ends. o/~
+  dq lit, -32*8, early_comma
+
+  ; If it's neither in the dictionary nor a number, exit.
+  dq litstring, "stack-deallocate-string-accumulator", early_find
+  dq entry_to_execution_token, early_comma
+  dq litstring, "litstring", early_find, entry_to_execution_token, early_comma
+  dq lit, "No such ", early_comma, lit, "word.", early_comma
+  dq litstring, "emitstring", early_find, entry_to_execution_token
+  dq early_comma
+  dq litstring, "exit", early_find, entry_to_execution_token, early_comma
   dq early_here, fetch, lit, 8, packalign, early_here_store
 
 
@@ -10333,7 +10455,7 @@ defword self_raw, 0
 defword foo, 0
   dq docol, litstring, "ia ia ftaghn", emitstring, exit
 defword boot_source, 0
-  dq "foo"
+  dq "6 7 * dot"
   dq 0
 
 ; Routines that traverse the raw code need a way to guess where the end of a