From 1ab48a69ccfa4ddaa2e1fa803ea6fe568b890abc Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Wed, 13 Feb 2019 11:28:21 -0800 Subject: 4960 I think I don't need to special-case packing for different segments. That should massively cut down on the number of tests. --- subx/apps/pack | Bin 20762 -> 20768 bytes subx/apps/pack.subx | 14 ++++++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/subx/apps/pack b/subx/apps/pack index ef1f5847..075dc69b 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 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) -> # 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 # -- cgit 1.4.1-2-gfad0