about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-02-13 11:28:21 -0800
committerKartik Agaram <vc@akkartik.com>2019-02-13 11:28:21 -0800
commit1ab48a69ccfa4ddaa2e1fa803ea6fe568b890abc (patch)
tree5d4cb3246258214cff0014087bdad72a319df4a9
parenta630d7fb9666bbacdd714ddc12d3c42ef1466ba7 (diff)
downloadmu-1ab48a69ccfa4ddaa2e1fa803ea6fe568b890abc.tar.gz
4960
I think I don't need to special-case packing for different segments. That
should massively cut down on the number of tests.
-rwxr-xr-xsubx/apps/packbin20762 -> 20768 bytes
-rw-r--r--subx/apps/pack.subx14
2 files changed, 6 insertions, 8 deletions
diff --git a/subx/apps/pack b/subx/apps/pack
index ef1f5847..075dc69b 100755
--- a/subx/apps/pack
+++ b/subx/apps/pack
Binary files differdiff --git a/subx/apps/pack.subx b/subx/apps/pack.subx
index 04814d66..07988399 100644
--- a/subx/apps/pack.subx
+++ b/subx/apps/pack.subx
@@ -84,12 +84,12 @@ $main:end:
 
 convert:  # in : (address buffered-file), out : (address buffered-file) -> <void>
     # pseudocode:
-    #   line = new-stream(512, 1)
+    #   var line = new-stream(512, 1)
     #   repeatedly
     #     clear-stream(line)
     #     EAX = read-line(in, line)
     #     if EAX == EOF break
-    #     convert-instruction(line, out, err, ed)
+    #     convert-instruction(line, out)
     #   flush(out)
     #
     # . prolog
@@ -122,14 +122,14 @@ $convert:loop:
     # if EAX == 0xffffffff break
     3d/compare-with-EAX  0xffffffff/imm32
     74/jump-if-equal  $convert:break/disp8
-    # convert-instruction(line, out, err, ed)
+    # convert-instruction(line, out)
     # . . push args
     ff          6/subop/push        1/mod/*+disp8   5/rm32/EBP    .           .             .           .           0xc/disp8       .                 # push *(EBP+12)
     51/push-ECX
     # . . call
     e8/call  convert-instruction/disp32
     # . . discard args
-    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               0x10/imm32        # add to ESP
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
 $convert:break:
     # flush(out)
     # . . push args
@@ -139,6 +139,8 @@ $convert:break:
     # . . discard args
     81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
 $convert:end:
+    # . reclaim locals
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               0x20c/imm32       # add to ESP
     # . restore registers
     59/pop-to-ECX
     # . epilog
@@ -202,10 +204,6 @@ convert-instruction:  # line : (address stream byte), out : (address buffered-fi
     #     write-stream-buffered(out, line)
     #     return
     #   if starts-with(word-slice, '==')
-    #     segment-name = next-word()
-    #     write-stream-buffered(out, line)
-    #     return
-    #   if segment-name != 'code'
     #     write-stream-buffered(out, line)
     #     return
     #