about summary refs log tree commit diff stats
path: root/subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-05-17 19:22:42 -0700
committerKartik Agaram <vc@akkartik.com>2019-05-17 19:31:18 -0700
commitd2308421a7d0f9cab0476c0aff6de9d55d6b7f42 (patch)
treec03f18df7464921a2409f221af7501561bbd008d /subx
parent72853d07bb3cfed09f57ee36b582f8f35fee74e4 (diff)
downloadmu-d2308421a7d0f9cab0476c0aff6de9d55d6b7f42.tar.gz
start of new syntax for segment headers
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:

  ```
  === <name> <address>
  ```

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
Diffstat (limited to 'subx')
-rwxr-xr-xsubx/apps/packbin37276 -> 37316 bytes
-rw-r--r--subx/apps/pack.subx52
2 files changed, 26 insertions, 26 deletions
diff --git a/subx/apps/pack b/subx/apps/pack
index 1f530400..01d35889 100755
--- a/subx/apps/pack
+++ b/subx/apps/pack
Binary files differdiff --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