summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--amd64.e2
-rw-r--r--hex.e2
-rw-r--r--transform.e47
3 files changed, 43 insertions, 8 deletions
diff --git a/amd64.e b/amd64.e
index c6dabb4..e647f9b 100644
--- a/amd64.e
+++ b/amd64.e
@@ -678,7 +678,7 @@ s" :cc-greater" keyword
 
 ~ (output point, source register, target register -- output point)
 : mov-reg64-reg64
-  ~ : 1 # # mov-reg64-reg64
+  ~ : 1 #swap # # mov-reg64-reg64
   3roll rex-w 0x89 pack8 3unroll
   swap reg64 swap addressing-reg64 ;
 : mov-indirect-reg64-reg64
diff --git a/hex.e b/hex.e
index d1c4e31..c9de9da 100644
--- a/hex.e
+++ b/hex.e
@@ -279,10 +279,12 @@
   0x08000000 L!' origin
   elf-file-header
   elf-program-header-writable
+  ~ : blank-line
   output-start-routine
   output-exit
   output-read-byte
   output-decode-nibble
+  ~ : blank-line
   output-error-handlers
   output-messages
 
diff --git a/transform.e b/transform.e
index 2227f2a..9816726 100644
--- a/transform.e
+++ b/transform.e
@@ -2778,6 +2778,7 @@ allocate-transformation-state s" transformation-state" variable
 ~   ~ : 1 suppress
 ~
 ~   ~ : Do a thing with # and # ?
+~   ~ : Do a different #swap # thing to # now.
 ~   ~ : provide-decimal
 ~   ~ : provide-hex8
 ~   ~ : provide-hex16
@@ -3127,6 +3128,14 @@ allocate-transformation-state s" transformation-state" variable
 ~ comment entry pops it off the substring entry stack and pretty-prints the
 ~ value it holds.
 ~
+~   One more thing: The order in which provide-* commands execute will most
+~ likely match the order in which the corresponding bytes are output. This may
+~ not always match the order in which the comment template wants to
+~ pretty-print them. Therefore, anywhere you can use # you can also use #swap
+~ to manipulate the substring-entry stack. The #swap command must be its own
+~ separate space-delimited word within a comment body; the space immediately
+~ following it is stripped from the output.
+~
 ~   It's probably clear from the extreme emphasis this documentation has taken
 ~ on describing the order things happen in, but it is quite common to define
 ~ a suffix comment at the start of an assembly-instruction word; adjust its
@@ -3699,6 +3708,7 @@ allocate-transformation-state s" transformation-state" variable
       ~ (input point, first non-word character or 0, word pointer)
 
       dup s" #" stringcmp 0 = {
+        ~ (input point, first non-word character or 0, word pointer)
         drop
 
         pop-substring-entry-stack
@@ -3737,20 +3747,43 @@ allocate-transformation-state s" transformation-state" variable
           dup hex-output-metadata-entry-string @ emitstring
         } if
 
-        drop
+        ~   Tidy up. We want to treat the next character normally, so we
+        ~ return a zero to indicate that.
+        drop 0
       } {
-        emitstring
+        dup s" #swap" stringcmp 0 = {
+          ~ (input point, first non-word character or 0, word pointer)
+          drop
+
+          pop-substring-entry-stack
+          pop-substring-entry-stack
+          swap
+          push-substring-entry-stack
+          push-substring-entry-stack
+
+          ~   We want to ignore the next character, so that this word can be
+          ~ used without creating spurious spaces in the output.
+          1
+        } {
+          ~ (input point, first non-word character or 0, word pointer)
+
+          ~   Here as well, we want to treat the next character normally, so
+          ~ we return zero.
+          emitstring 0
+        } if-else
       } if-else
-      ~ (input point, first non-word character or 0)
+      ~ (input point, first non-word character or 0, should ignore space)
 
-      dup {
+      over {
         ~   If the character is non-zero, it's a space, so it can't be part of
-        ~ a word, so we can output it.
-        value@ emitstring drop
+        ~ a word, so we can output it... unless we were asked to skip it,
+        ~ of course.
+        not { value@ emitstring } if
+        drop
       } {
         ~   If this is the end of the string, we can discard the 0, but then
         ~ we need to nudge the input point back so the loop will terminate.
-        drop 1-
+        drop drop 1-
       } if-else
       ~ (input point)
     } if-else