about summary refs log tree commit diff stats
path: root/subx/apps
diff options
context:
space:
mode:
Diffstat (limited to 'subx/apps')
-rwxr-xr-xsubx/apps/packbin47007 -> 47016 bytes
-rw-r--r--subx/apps/pack.subx59
2 files changed, 30 insertions, 29 deletions
diff --git a/subx/apps/pack b/subx/apps/pack
index a44b4e50..efd22fef 100755
--- a/subx/apps/pack
+++ b/subx/apps/pack
Binary files differdiff --git a/subx/apps/pack.subx b/subx/apps/pack.subx
index 6fef5c37..61a837ba 100644
--- a/subx/apps/pack.subx
+++ b/subx/apps/pack.subx
@@ -939,16 +939,16 @@ convert-data:  # line : (address stream byte), out : (address buffered-file) ->
     #       break  # skip emitting some whitespace
     #     if slice-starts-with?(word-slice, "#")      # comment
     #       write-slice-buffered(out, word-slice)
-    #       break
+    #       return
     #     if slice-ends-with?(word-slice, ":")        # label
-    #       write-buffered(out, "\n")  # put labels on their own line
     #       write-stream-data(out, line)
-    #       break
+    #       return
     #     if has-metadata?(word-slice, "imm32")
     #       emit(out, word-slice, 4)
     #     # disp32 is not permitted in data segments, and anything else is only a byte long
     #     else
     #       emit(out, word-slice, 1)
+    #   write-buffered(out, "\n")
     #
     # . prolog
     55/push-EBP
@@ -1049,7 +1049,7 @@ $convert-data:check0:
     81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
     # . if (EAX != 0) break
     3d/compare-EAX-and  0/imm32
-    0f 85/jump-if-not-equal  $convert-data:end/disp32
+    0f 85/jump-if-not-equal  $convert-data:break/disp32
 $convert-data:check-for-comment:
     # if (slice-starts-with?(word-slice, "#"))
     # . start/EDX = word-slice->start
@@ -1069,8 +1069,8 @@ $convert-data:comment:
     e8/call  write-slice-buffered/disp32
     # . . discard args
     81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
-    # break
-    75/jump-if-not-equal  $convert-data:end/disp8
+    # return
+    0f 85/jump-if-not-equal  $convert-data:end/disp32
 $convert-data:check-for-label:
     # if (slice-ends-with?(word-slice, ":"))
     # . end/EDX = word-slice->end
@@ -1082,14 +1082,6 @@ $convert-data:check-for-label:
     3d/compare-EAX-and  0x3a/imm32/colon
     75/jump-if-not-equal  $convert-data:check-for-imm32/disp8
 $convert-data:label:
-    # write-buffered(out, "\n")
-    # . . push args
-    68/push  "\n"/imm32
-    ff          6/subop/push        1/mod/*+disp8   5/rm32/EBP    .           .             .           .           0xc/disp8       .                 # push *(EBP+12)
-    # . . call
-    e8/call  write-buffered/disp32
-    # . . discard args
-    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
     # write-stream-data(out, line)
     # . . push args
     ff          6/subop/push        1/mod/*+disp8   5/rm32/EBP    .           .             .           .           8/disp8         .                 # push *(EBP+8)
@@ -1098,7 +1090,7 @@ $convert-data:label:
     e8/call  write-stream-data/disp32
     # . . discard args
     81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
-    # break
+    # return
     75/jump-if-not-equal  $convert-data:end/disp8
 $convert-data:check-for-imm32:
     # if (has-metadata?(word-slice, "imm32"))
@@ -1135,6 +1127,15 @@ $convert-data:single-byte:
     # . . discard args
     81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               0xc/imm32         # add to ESP
     e9/jump  $convert-data:loop/disp32
+$convert-data:break:
+    # write-buffered(out, "\n")
+    # . . push args
+    68/push  "\n"/imm32
+    ff          6/subop/push        1/mod/*+disp8   5/rm32/EBP    .           .             .           .           0xc/disp8       .                 # push *(EBP+12)
+    # . . call
+    e8/call  write-buffered/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
 $convert-data:end:
     # . reclaim locals
     81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
@@ -1295,10 +1296,10 @@ test-convert-data-passes-labels-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, "\nab: # cd", msg)
+    # . check-stream-equal(_test-output-stream, "ab: # cd", msg)
     # . . push args
     68/push  "F - test-convert-data-passes-labels-through"/imm32
-    68/push  "\nab: # cd"/imm32
+    68/push  "ab: # cd"/imm32
     68/push  _test-output-stream/imm32
     # . . call
     e8/call  check-stream-equal/disp32
@@ -1364,10 +1365,10 @@ test-convert-data-passes-names-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/imm32", msg)
+    # . check-stream-equal(_test-output-stream, "abcd/imm32 \n", msg)
     # . . push args
     68/push  "F - test-convert-data-passes-names-through"/imm32
-    68/push  "abcd/imm32 "/imm32
+    68/push  "abcd/imm32 \n"/imm32
     68/push  _test-output-stream/imm32
     # . . call
     e8/call  check-stream-equal/disp32
@@ -1432,10 +1433,10 @@ test-convert-data-handles-imm32:
     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, "30 00 00 00 ", msg)
+    # . check-stream-equal(_test-output-stream, "30 00 00 00 \n", msg)
     # . . push args
     68/push  "F - test-convert-data-handles-imm32"/imm32
-    68/push  "30 00 00 00 "/imm32
+    68/push  "30 00 00 00 \n"/imm32
     68/push  _test-output-stream/imm32
     # . . call
     e8/call  check-stream-equal/disp32
@@ -1501,10 +1502,10 @@ test-convert-data-handles-single-byte:
     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, "30 ", msg)
+    # . check-stream-equal(_test-output-stream, "30 \n", msg)
     # . . push args
     68/push  "F - test-convert-data-handles-single-byte"/imm32
-    68/push  "30 "/imm32
+    68/push  "30 \n"/imm32
     68/push  _test-output-stream/imm32
     # . . call
     e8/call  check-stream-equal/disp32
@@ -1569,10 +1570,10 @@ test-convert-data-multiple-bytes:
     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, "01 02 ", msg)
+    # . check-stream-equal(_test-output-stream, "01 02 \n", msg)
     # . . push args
     68/push  "F - test-convert-data-multiple-bytes"/imm32
-    68/push  "01 02 "/imm32
+    68/push  "01 02 \n"/imm32
     68/push  _test-output-stream/imm32
     # . . call
     e8/call  check-stream-equal/disp32
@@ -1637,10 +1638,10 @@ test-convert-data-byte-then-name:
     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, "30 abcd/o ", msg)
+    # . check-stream-equal(_test-output-stream, "30 abcd/o \n", msg)
     # . . push args
     68/push  "F - test-convert-data-byte-then-name"/imm32
-    68/push  "30 abcd/o "/imm32
+    68/push  "30 abcd/o \n"/imm32
     68/push  _test-output-stream/imm32
     # . . call
     e8/call  check-stream-equal/disp32
@@ -1731,10 +1732,10 @@ test-convert-data-multiple-words:
 #?     # . . discard args
 #?     81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
 #?     # }}}
-    # . check-stream-equal(_test-output-stream, "30 abcd/o 42 e1 00 00 ", msg)
+    # . check-stream-equal(_test-output-stream, "30 abcd/o 42 e1 00 00 \n", msg)
     # . . push args
     68/push  "F - test-convert-data-multiple-words"/imm32
-    68/push  "30 abcd/o e1 42 00 00 "/imm32
+    68/push  "30 abcd/o e1 42 00 00 \n"/imm32
     68/push  _test-output-stream/imm32
     # . . call
     e8/call  check-stream-equal/disp32