From 2eb637e63a9e5d8f87391beb4af6019963a7c36c Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Thu, 10 Sep 2026 09:22:12 -0700 Subject: add provide-hex, which varies its output width to fit the value and amd64.e uses it for all the immediates, but not for other kinds of numeric parameter, which looks pretty slick and readable Force-Push: yes Change-Id: Ifb630a4dc172d7495b5458316266fe76b75e07af --- transform.e | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'transform.e') diff --git a/transform.e b/transform.e index 5bec117..b8afb1d 100644 --- a/transform.e +++ b/transform.e @@ -2780,6 +2780,7 @@ allocate-transformation-state s" transformation-state" variable ~ ~ : Do a thing with # and # ? ~ ~ : Do a different #swap # thing to # now. ~ ~ : provide-decimal +~ ~ : provide-hex ~ ~ : provide-hex8 ~ ~ : provide-hex16 ~ ~ : provide-hex32 @@ -3204,14 +3205,15 @@ allocate-transformation-state s" transformation-state" variable : hex-output-metadata-entry-type-raw-string-literal 6 ; : hex-output-metadata-entry-type-alignment 7 ; : hex-output-metadata-entry-type-push-substring-decimal 8 ; -: hex-output-metadata-entry-type-push-substring-hex8 9 ; -: hex-output-metadata-entry-type-push-substring-hex16 10 ; -: hex-output-metadata-entry-type-push-substring-hex32 11 ; -: hex-output-metadata-entry-type-push-substring-hex64 12 ; -: hex-output-metadata-entry-type-push-substring-string 13 ; -: hex-output-metadata-entry-type-drop-substring 14 ; -: hex-output-metadata-entry-type-swap-substrings 15 ; -: hex-output-metadata-entry-type-roll-substrings 16 ; +: hex-output-metadata-entry-type-push-substring-hex 9 ; +: hex-output-metadata-entry-type-push-substring-hex8 10 ; +: hex-output-metadata-entry-type-push-substring-hex16 11 ; +: hex-output-metadata-entry-type-push-substring-hex32 12 ; +: hex-output-metadata-entry-type-push-substring-hex64 13 ; +: hex-output-metadata-entry-type-push-substring-string 14 ; +: hex-output-metadata-entry-type-drop-substring 15 ; +: hex-output-metadata-entry-type-swap-substrings 16 ; +: hex-output-metadata-entry-type-roll-substrings 17 ; ~ 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 @@ -3263,6 +3265,7 @@ allocate-transformation-state s" transformation-state" variable ~ push-substring entries. hex-output-metadata-entry-type @ dup hex-output-metadata-entry-type-push-substring-decimal = swap + dup hex-output-metadata-entry-type-push-substring-hex = 3roll || swap dup hex-output-metadata-entry-type-push-substring-hex8 = 3roll || swap dup hex-output-metadata-entry-type-push-substring-hex16 = 3roll || swap dup hex-output-metadata-entry-type-push-substring-hex32 = 3roll || swap @@ -3795,6 +3798,12 @@ allocate-transformation-state s" transformation-state" variable dup hex-output-metadata-entry-string @ . } if + dup hex-output-metadata-entry-type @ + hex-output-metadata-entry-type-push-substring-hex = { + ." 0x" + dup hex-output-metadata-entry-string @ .hex + } if + dup hex-output-metadata-entry-type @ hex-output-metadata-entry-type-push-substring-hex8 = { ." 0x" @@ -4935,6 +4944,13 @@ allocate-transformation-state s" transformation-state" variable add-hex-output-metadata-entry exit } if + dup s" provide-hex" stringcmp 0 = { + ~ Create a new "push substring hex" entry. + drop drop + 2 pick hex-output-metadata-entry-type-push-substring-hex swap + add-hex-output-metadata-entry + exit + } if dup s" provide-hex8" stringcmp 0 = { ~ Create a new "push substring hex8" entry. drop drop -- cgit 1.4.1