From a41c6444d30f9ad561d95a1776f796581338df16 Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Fri, 28 Aug 2026 22:21:52 -0700 Subject: make read-to-buffer take its delimiter as a parameter since the recommended invocation to build Evocation (hehe) does the heavy lifting in interpreted mode, this required a new helper, allocate-string, which takes a string in the scratch space and properly allocates it so it won't be overwritten by future allocations Force-Push: yes Change-Id: Ia73612a65fd7c11af5fe110c573c23c16b777112 --- README.txt | 4 ++-- dynamic.e | 9 +++++++++ evoke.e | 4 ++-- quine.asm | 25 +++++++++++++++++++++++++ transform.e | 8 ++++---- 5 files changed, 42 insertions(+), 8 deletions(-) diff --git a/README.txt b/README.txt index bf11f9c..e985cc4 100644 --- a/README.txt +++ b/README.txt @@ -20,12 +20,12 @@ it needs to, yet. This is a working Evocation interpreter, but it's incomplete and will become more so with time. So, next, build Evocation-in-Evocation: - $ (cat labels.e elf.e transform.e execution.e; echo 262144 read-to-buffer; cat core.e linux.e output.e amd64.e execution-support.e log-load.e; echo pyrzqxgl 262144 read-to-buffer; cat core.e linux.e output.e amd64.e execution-support.e log-load.e dynamic.e input.e interpret.e flow-control.e linux-dynamic.e ; echo pyrzqxgl; cat evoke.e) | ./quine > evoke + $ (cat labels.e elf.e transform.e execution.e; echo 's" pyrzqxgl" allocate-string dup 262144 read-to-buffer'; cat core.e linux.e output.e amd64.e execution-support.e log-load.e; echo pyrzqxgl swap 262144 read-to-buffer; cat core.e linux.e output.e amd64.e execution-support.e log-load.e dynamic.e input.e interpret.e flow-control.e linux-dynamic.e ; echo pyrzqxgl; cat evoke.e) | ./quine > evoke $ chmod 755 evoke Finally, rebuild Evocation-in-Evocation with itself: - $ (cat labels.e elf.e transform.e execution.e; echo 262144 read-to-buffer; cat core.e linux.e output.e amd64.e execution-support.e log-load.e; echo pyrzqxgl 262144 read-to-buffer; cat core.e linux.e output.e amd64.e execution-support.e log-load.e dynamic.e input.e interpret.e flow-control.e linux-dynamic.e ; echo pyrzqxgl; cat evoke.e) | ./evoke > evoke2 + $ (cat labels.e elf.e transform.e execution.e; echo 's" pyrzqxgl" allocate-string dup 262144 read-to-buffer'; cat core.e linux.e output.e amd64.e execution-support.e log-load.e; echo pyrzqxgl swap 262144 read-to-buffer; cat core.e linux.e output.e amd64.e execution-support.e log-load.e dynamic.e input.e interpret.e flow-control.e linux-dynamic.e ; echo pyrzqxgl; cat evoke.e) | ./evoke > evoke2 $ chmod 755 evoke2 Now keep your evoke binary somewhere safe, and use it to build new versions diff --git a/dynamic.e b/dynamic.e index a02eec0..af5d9b2 100644 --- a/dynamic.e +++ b/dynamic.e @@ -348,6 +348,15 @@ 3roll + 8 packalign here ! ; +~ Takes a string pointer which must be equal to the current value of "here", +~ indicating it is in the temporary allocation space, and allocates it +~ permanently by advancing "here" to the next aligned address after it. +~ +~ (string pointer -- string pointer) +: allocate-string + dup dup stringlen 1+ + 8 packalign here ! ; + + ~ Allocate space by incrementing "here", and output a word entry header in ~ it. Also add it to the "latest" linked list. Use zero as the flag values; ~ accept a string pointer on the stack and use its contents as the name. diff --git a/evoke.e b/evoke.e index 41c3687..ddb6135 100644 --- a/evoke.e +++ b/evoke.e @@ -1,7 +1,7 @@ ~ (cat labels.e elf.e transform.e execution.e \ -~ echo 262144 read-to-buffer; \ +~ echo 's" pyrzqxgl" allocate-string dup 262144 read-to-buffer'; \ ~ cat core.e linux.e output.e amd64.e execution-support.e log-load.e; \ -~ echo pyrzqxgl 262144 read-to-buffer; \ +~ echo pyrzqxgl swap 262144 read-to-buffer; \ ~ cat core.e linux.e output.e amd64.e execution-support.e log-load.e \ ~ dynamic.e input.e interpret.e flow-control.e linux-dynamic.e; \ ~ echo 0 sys-exit pyrzqxgl; \ diff --git a/quine.asm b/quine.asm index f11b435..28f97d1 100644 --- a/quine.asm +++ b/quine.asm @@ -6255,6 +6255,31 @@ cold_start: dq litstring, "exit", early_find, entry_to_execution_token, early_comma dq early_here, fetch, lit, 8, packalign, early_here_store + ; Takes a string pointer which must be equal to the current value of + ; "here", ; indicating it is in the temporary allocation space, and + ; allocates it permanently by advancing "here" to the next aligned address + ; after it. + ; + ; In: + ; string pointer + ; Out: + ; string pointer + dq litstring, "allocate-string", early_create, early_docol_codeword + dq litstring, "dup", early_find, entry_to_execution_token, early_comma + dq litstring, "dup", early_find, entry_to_execution_token, early_comma + dq litstring, "stringlen", 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, "+", early_find, entry_to_execution_token, early_comma + dq litstring, "lit", early_find, entry_to_execution_token, early_comma + dq lit, 8, early_comma + dq litstring, "packalign", early_find, entry_to_execution_token, early_comma + dq litstring, "here", early_find, entry_to_execution_token, early_comma + dq litstring, "!", 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 + ; In: ; pointer to buffer metadata ; Out: diff --git a/transform.e b/transform.e index 313882d..ff37ea6 100644 --- a/transform.e +++ b/transform.e @@ -203,7 +203,7 @@ ~ implementations of both transforms. ~ TODO all this buffer stuff should be in its own file -~ (buffer size -- buffer address) +~ (delimiter pointer, buffer size -- buffer address) : read-to-buffer dup allocate dup dup ~ (buffer size, buffer address, word start, output point) @@ -212,7 +212,7 @@ dup not { ~ Make sure to pack the zero to serve as a null terminator. pack8 - drop drop swap drop exit } if + drop drop swap drop swap drop exit } if dup is-space { ~ (buffer size, buffer address, word start, output point, key) ~ Tuck the key out of the way until we've done some stuff. @@ -224,12 +224,12 @@ ~ Add a null terminator so we can use stringcmp dup 0 swap ! ~ Check for the magic word - over s" pyrzqxgl" stringcmp 0 = + over 6 pick stringcmp 0 = } if { ~ It's magic, so exit. ~ Make sure to pack a zero to serve as a null terminator. 0 pack8 - drop drop drop swap drop exit } + drop drop drop swap drop swap drop exit } { ~ It's not magic, so reset the word start. Of course whitespace is ~ not a word but this will help us keep track of things. 3roll pack8 -- cgit 1.4.1