summary refs log tree commit diff
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2026-09-15 18:00:31 -0700
committerIrene Knapp <ireneista@irenes.space>2026-09-15 18:00:31 -0700
commite1f5c4e72830cc9ce900e1884d3338f1c82060fd (patch)
tree5e7378c0fc9dc934a0592389c169ef9c0ca25a46
parent9ac5b1f59144c13d2bdb1508f4e4f820db00bf48 (diff)
redo the hex dump comments for alignment to use the regular magic commands
previously, alignment had been a special-cased type of metadata entry, with a special trap on packalign. now it uses the same programmable setup everything else does. much simpler, and prettier output.

this CL also contains some modest reformatting of section headers in the hex dump

Force-Push: yes
Change-Id: I21554e92f6af6ddefa937dad8073b89657f85d64
-rw-r--r--core.e8
-rw-r--r--evoke.e4
-rw-r--r--execution.e12
-rw-r--r--transform.e104
4 files changed, 30 insertions, 98 deletions
diff --git a/core.e b/core.e
index 44f9fd5..e181d4f 100644
--- a/core.e
+++ b/core.e
@@ -1219,8 +1219,14 @@ here !
 
 ~ (output point, alignment byte width -- output point)
 : packalign
+  ~   It's possible the padding will be of length zero, so we have to put the
+  ~ magic comment provide-* command first.
+  ~ : provide-decimal
+  ~ : 0 Alignment padding to width #
   { 2dup /% drop { drop exit } unless
-    swap 0 pack8 swap } forever ;
+    swap 0 pack8 swap
+    ~ : 1 adjust-length
+  } forever ;
 
 
 ~ Binary unpacking
diff --git a/evoke.e b/evoke.e
index 1e9e881..8faed81 100644
--- a/evoke.e
+++ b/evoke.e
@@ -18,6 +18,10 @@ s" source-to-precompile" variable
 ~ Everything directly called by all-contents has this same interface.
 ~
 : all-contents
+  ~ :   This particular program is 'evoke', the compiler. If you already have
+  ~ : a binary copy of 'hex', run this file through it and you'll have a
+  ~ : working compiler. Pretty sweet, right?
+  ~ : blank-line
   0x08000000 L!' origin
 
   elf-file-header
diff --git a/execution.e b/execution.e
index 66f04d1..649784c 100644
--- a/execution.e
+++ b/execution.e
@@ -238,9 +238,9 @@
 : output-cold-start
   ~ : blank-line
   ~ : blank-line
-  ~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~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
   ~ : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   ~ : blank-line
   ~ :   This is the start of a long block of code which has been processed by
@@ -3275,17 +3275,16 @@ allocate-transformation-state s" transformation-state" variable
 : hex-output-metadata-entry-type-indent 4 ;
 : hex-output-metadata-entry-type-string-literal 5 ;
 : hex-output-metadata-entry-type-raw-string-literal 6 ;
-: hex-output-metadata-entry-type-alignment 7 ;
-: hex-output-metadata-entry-type-push-subitem-decimal 8 ;
-: hex-output-metadata-entry-type-push-subitem-hex 9 ;
-: hex-output-metadata-entry-type-push-subitem-hex8 10 ;
-: hex-output-metadata-entry-type-push-subitem-hex16 11 ;
-: hex-output-metadata-entry-type-push-subitem-hex32 12 ;
-: hex-output-metadata-entry-type-push-subitem-hex64 13 ;
-: hex-output-metadata-entry-type-push-subitem-string 14 ;
-: hex-output-metadata-entry-type-drop-subitem 15 ;
-: hex-output-metadata-entry-type-swap-subitems 16 ;
-: hex-output-metadata-entry-type-roll-subitems 17 ;
+: hex-output-metadata-entry-type-push-subitem-decimal 7 ;
+: hex-output-metadata-entry-type-push-subitem-hex 8 ;
+: hex-output-metadata-entry-type-push-subitem-hex8 9 ;
+: hex-output-metadata-entry-type-push-subitem-hex16 10 ;
+: hex-output-metadata-entry-type-push-subitem-hex32 11 ;
+: hex-output-metadata-entry-type-push-subitem-hex64 12 ;
+: hex-output-metadata-entry-type-push-subitem-string 13 ;
+: hex-output-metadata-entry-type-drop-subitem 14 ;
+: hex-output-metadata-entry-type-swap-subitems 15 ;
+: hex-output-metadata-entry-type-roll-subitems 16 ;
 
 ~   Initialize the contents of the output metadata to all zeroes. This is
 ~ called from hex-transform at its top level, at the very start, to make sure
@@ -4124,19 +4123,6 @@ allocate-transformation-state s" transformation-state" variable
           0 current-column!
         } if
 
-        dup hex-output-metadata-entry-type @
-        hex-output-metadata-entry-type-alignment = {
-          fresh-line
-          indentation-depth@ dup indent advance-current-column
-
-          ." ~ Alignment padding to width "
-          dup hex-output-metadata-entry-content @ .
-
-          newline
-          1 is-fresh-line!
-          0 current-column!
-        } if
-
         dup is-push-subitem-entry {
           dup push-subitem-entry-stack
         } if
@@ -4629,70 +4615,6 @@ allocate-transformation-state s" transformation-state" variable
     exit
   } if
 
-  dup s" packalign" stringcmp 0 = {
-    create dropstring
-    s" docol" find entry-to-execution-token execute ,
-    make-hidden
-
-    ~ (output point, alignment byte width)
-    s" 2dup" find entry-to-execution-token ,
-
-    ~   We can't use unpackalign because this patch happens at the time
-    ~ packalign is being defined, and it would be a forward reference. We do
-    ~ the equivalent by hand.
-    s" dup" find entry-to-execution-token ,
-    s" 3unroll" find entry-to-execution-token ,
-    s" dup" find entry-to-execution-token ,
-    s" 3unroll" find entry-to-execution-token ,
-    s" 1-" find entry-to-execution-token ,
-    s" +" find entry-to-execution-token ,
-    s" swap" find entry-to-execution-token ,
-    s" /%" find entry-to-execution-token ,
-    s" swap" find entry-to-execution-token ,
-    s" drop" find entry-to-execution-token ,
-    s" *" find entry-to-execution-token ,
-    ~ (output point, alignment byte width, padding end)
-
-    ~ We can't use pick, either.
-    s" 3roll" find entry-to-execution-token ,
-    s" dup" find entry-to-execution-token ,
-    s" dup" find entry-to-execution-token ,
-    s" lit" find entry-to-execution-token ,
-    5 ,
-    s" unroll" find entry-to-execution-token ,
-    ~ (output point, alignment byte width, padding end, output point,
-    ~  output point)
-
-    s" 3unroll" find entry-to-execution-token ,
-    s" -" find entry-to-execution-token ,
-    ~ (output point, alignment byte width, padding start, padding length)
-
-    ~   This would be the place to put a call to hex-pack-trace, but packalign
-    ~ is implemented using pack8, so it's not necessary.
-
-    ' hex-output-metadata-entry-type-alignment entry-to-execution-token ,
-    ~ (output point, alignment byte width, padding start, padding length,,
-    ~  entry type)
-
-    ~ Again, no pick.
-    s" lit" find entry-to-execution-token ,
-    4 ,
-    s" roll" find entry-to-execution-token ,
-    s" dup" find entry-to-execution-token ,
-    s" lit" find entry-to-execution-token ,
-    5 ,
-    s" unroll" find entry-to-execution-token ,
-
-    ~ (output point, alignment byte width, padding start, padding length,
-    ~  entry type, alignment byte width)
-    ' add-hex-output-metadata-entry entry-to-execution-token ,
-    ~ (output point, alignment byte width)
-    ~ Fall through to the inner implementation.
-
-    ' ] entry-to-execution-token execute
-    exit
-  } if
-
   ~   If no special case matches, we fall back to just being a regular colon.
   ~ We already read the word name above, so we have to do the rest of the
   ~ steps ourselves as well.