From d2308421a7d0f9cab0476c0aff6de9d55d6b7f42 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Fri, 17 May 2019 19:22:42 -0700 Subject: start of new syntax for segment headers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Right now SubX defines headers with the following syntax: ``` === ... ``` The `...` can be either a numeric address or a name. Numeric addresses are useful for tests where we want to check addresses of individual instructions. Names are useful in real programs where we want to add to a segment in many places. This approach has long seemed a mess. It's hard to explain, and there's a certain amount of historical evolution that led to it that should be irrelevant to comprehend the current state of the codebase. I started out assuming the first segment was always code, before adding the special names 'code' and 'data'. We pretend to support more than two segments but we don't really. To simplify the code and explanation we'll move to a new syntax: ``` ===
``` Code will always belong in the special name 'code', but it no longer has to be first. We need to migrate both our SubX-in-SubX phases and the C++ version. The plan is to start from the top down and update bootstrapping phases that've already been built (see commit 5102 for the list of phases). This commit updates pack.subx. Current state: ✓ hex.subx (no changes required) survey.subx ✓ pack.subx (fixed here) assort.subx dquotes.subx --- subx/apps/pack | Bin 37276 -> 37316 bytes subx/apps/pack.subx | 52 ++++++++++++++++++++++++++-------------------------- 2 files changed, 26 insertions(+), 26 deletions(-) (limited to 'subx') diff --git a/subx/apps/pack b/subx/apps/pack index 1f530400..01d35889 100755 Binary files a/subx/apps/pack and b/subx/apps/pack differ diff --git a/subx/apps/pack.subx b/subx/apps/pack.subx index 88ed23b6..c035c361 100644 --- a/subx/apps/pack.subx +++ b/subx/apps/pack.subx @@ -570,9 +570,9 @@ test-convert-passes-segment-headers-through: # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP # initialize input - # . write(_test-input-stream, "== abcd") + # . write(_test-input-stream, "== abcd 0x1") # . . push args - 68/push "== abcd"/imm32 + 68/push "== abcd 0x1"/imm32 68/push _test-input-stream/imm32 # . . call e8/call write/disp32 @@ -594,10 +594,10 @@ test-convert-passes-segment-headers-through: e8/call flush/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - # . check-stream-equal(_test-output-stream, "== abcd", msg) + # . check-stream-equal(_test-output-stream, "== abcd 0x1", msg) # . . push args 68/push "F - test-convert-passes-segment-headers-through"/imm32 - 68/push "== abcd"/imm32 + 68/push "== abcd 0x1"/imm32 68/push _test-output-stream/imm32 # . . call e8/call check-stream-equal/disp32 @@ -647,20 +647,20 @@ test-convert-in-data-segment: # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP # initialize input - # == code - # == data + # == code 0x1 + # == data 0x2 # 3 4/imm32 - # . write(_test-input-stream, "== code") + # . write(_test-input-stream, "== code 0x1") # . . push args - 68/push "== code\n"/imm32 + 68/push "== code 0x1\n"/imm32 68/push _test-input-stream/imm32 # . . call e8/call write/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "== data\n") + # . write(_test-input-stream, "== data 0x2\n") # . . push args - 68/push "== data\n"/imm32 + 68/push "== data 0x2\n"/imm32 68/push _test-input-stream/imm32 # . . call e8/call write/disp32 @@ -716,19 +716,19 @@ test-convert-in-data-segment: e8/call flush/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - # . check-next-stream-line-equal(_test-output-stream, "== code", msg) + # . check-next-stream-line-equal(_test-output-stream, "== code 0x1", msg) # . . push args 68/push "F - test-convert-in-data-segment/0"/imm32 - 68/push "== code"/imm32 + 68/push "== code 0x1"/imm32 68/push _test-output-stream/imm32 # . . call e8/call check-next-stream-line-equal/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - # . check-next-stream-line-equal(_test-output-stream, "== data", msg) + # . check-next-stream-line-equal(_test-output-stream, "== data 0x2", msg) # . . push args 68/push "F - test-convert-in-data-segment/1"/imm32 - 68/push "== data"/imm32 + 68/push "== data 0x2"/imm32 68/push _test-output-stream/imm32 # . . call e8/call check-next-stream-line-equal/disp32 @@ -787,14 +787,14 @@ test-convert-code-and-data-segments: # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP # initialize input - # == code + # == code 0x1 # e8/call 20/disp32 # 68/push 0x20/imm8 - # == data + # == data 0x2 # 3 4/imm32 - # . write(_test-input-stream, "== code\n") + # . write(_test-input-stream, "== code 0x1\n") # . . push args - 68/push "== code\n"/imm32 + 68/push "== code 0x1\n"/imm32 68/push _test-input-stream/imm32 # . . call e8/call write/disp32 @@ -816,9 +816,9 @@ test-convert-code-and-data-segments: e8/call write/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . write(_test-input-stream, "== data\n") + # . write(_test-input-stream, "== data 0x2\n") # . . push args - 68/push "== data\n"/imm32 + 68/push "== data 0x2\n"/imm32 68/push _test-input-stream/imm32 # . . call e8/call write/disp32 @@ -841,10 +841,10 @@ test-convert-code-and-data-segments: # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP # check output - # == code + # == code 0x1 # e8 20 00 00 00 # e8/call 20/disp32 # 68 20 # 68/push 0x20/imm8 - # == data + # == data 0x2 # 03 04 00 00 00 #? # debug print {{{ #? # . write(2/stderr, "^") @@ -879,10 +879,10 @@ test-convert-code-and-data-segments: e8/call flush/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - # . check-next-stream-line-equal(_test-output-stream, "== code", msg) + # . check-next-stream-line-equal(_test-output-stream, "== code 0x1", msg) # . . push args 68/push "F - test-convert-code-and-data-segments/0"/imm32 - 68/push "== code"/imm32 + 68/push "== code 0x1"/imm32 68/push _test-output-stream/imm32 # . . call e8/call check-next-stream-line-equal/disp32 @@ -906,10 +906,10 @@ test-convert-code-and-data-segments: e8/call check-next-stream-line-equal/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - # . check-next-stream-line-equal(_test-output-stream, "== data", msg) + # . check-next-stream-line-equal(_test-output-stream, "== data 0x2", msg) # . . push args 68/push "F - test-convert-code-and-data-segments/3"/imm32 - 68/push "== data"/imm32 + 68/push "== data 0x2"/imm32 68/push _test-output-stream/imm32 # . . call e8/call check-next-stream-line-equal/disp32 -- cgit 1.4.1-2-gfad0