summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--README.txt4
-rw-r--r--dynamic.e9
-rw-r--r--evoke.e4
-rw-r--r--quine.asm25
-rw-r--r--transform.e8
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