summary refs log tree commit diff
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2025-11-29 17:58:39 -0800
committerIrene Knapp <ireneista@irenes.space>2025-11-29 17:58:39 -0800
commit17baa2f5ab52e6ce9f7a6af19bfaad0b5cfbc4c1 (patch)
tree2253bc77f5801158fdb538fc0b8c80e5e0c57b9b
parent445bc67265016be9867127bb5fa38341c5ef9dc0 (diff)
add words to find the next newer entry in the dictionary HEAD main
these are fully debugged. they'll be used for the decompile-and-recompile copy logic

Force-Push: yes
Change-Id: I25ba5c5934fc3d181dadcfb4cce09727dbacf70f
-rw-r--r--quine.asm28
1 files changed, 28 insertions, 0 deletions
diff --git a/quine.asm b/quine.asm
index c13744f..990f0ae 100644
--- a/quine.asm
+++ b/quine.asm
@@ -4878,6 +4878,34 @@ defword find_in, 0
   ; If we're here, it's a match. Clean up our working state and exit.
   dq swap, drop, exit
 
+; Stack in:
+;   heap address
+;   entry address
+; Stack out:
+;   entry address or 0
+defword early_next_newer_entry, 0
+  dq docol
+  dq swap, early_latest, fetch, swap, unroll3, swap, next_newer_entry_in
+  dq exit
+
+; Stack in:
+;   dictionary to search within
+;   entry address
+; Stack out:
+;   entry address or 0
+defword next_newer_entry_in, 0
+  dq docol
+  ; Dictionary pointer on top
+  dq swap
+  ; Exit if null
+  dq dup, lit, 0, eq, zbranch, 4*8, swap, drop, exit
+  ; Test if it's a match
+  dq dup2, fetch, ne, zbranch, 4*8
+  ; Non-match case; loop
+  dq fetch, branch, -16*8
+  ; Match case; return
+  dq swap, drop, exit
+
 ;   Jonesforth calls this "TFCA" and ">CFA"; its author speculates that the
 ; original meaning is "code field address".
 defword entry_to_execution_token, 0