From 0527fd92cb4748c72c4128c6aae7499e6d5b0c92 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Mon, 11 Feb 2019 22:58:25 -0800 Subject: 4956 --- subx/apps/pack | Bin 20534 -> 20762 bytes subx/apps/pack.subx | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/subx/apps/pack b/subx/apps/pack index f1c03684..ef1f5847 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 fada02f1..04814d66 100644 --- a/subx/apps/pack.subx +++ b/subx/apps/pack.subx @@ -21,7 +21,7 @@ # . 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes # for debugging: run a single test -#? e8/call test-convert-instruction-passes-comments-through/disp32 +#? e8/call test-convert-instruction-passes-labels-through/disp32 #? 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/EBX Num-test-failures/disp32 # copy *Num-test-failures to EBX #? eb/jump $main:end/disp8 @@ -507,6 +507,74 @@ test-convert-instruction-passes-lines-with-just-whitespace-through: 5d/pop-to-EBP c3/return +test-convert-instruction-passes-labels-through: + # if the first word ends with ':', pass along the entire line unchanged + # . prolog + 55/push-EBP + 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP + # setup + # . clear-stream(_test-stream) + # . . push args + 68/push _test-stream/imm32 + # . . call + e8/call clear-stream/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + # . clear-stream(_test-buffered-file+4) + # . . push args + b8/copy-to-EAX _test-buffered-file/imm32 + 05/add-to-EAX 4/imm32 + 50/push-EAX + # . . call + e8/call clear-stream/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + # . clear-stream(_test-tmp-stream) + # . . push args + 68/push _test-tmp-stream/imm32 + # . . call + e8/call clear-stream/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + # initialize input + # . write(_test-tmp-stream, "ab: # cd") + # . . push args + 68/push "ab: # cd"/imm32 + 68/push _test-tmp-stream/imm32 + # . . call + e8/call write/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # convert-instruction(_test-tmp-stream, _test-buffered-file) + # . . push args + 68/push _test-buffered-file/imm32 + 68/push _test-tmp-stream/imm32 + # . . call + e8/call convert-instruction/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # check that the write happened as expected + # . flush(_test-buffered-file) + # . . push args + 68/push _test-buffered-file/imm32 + # . . call + 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-stream, "ab: # cd", msg) + # . . push args + 68/push "F - test-convert-instruction-passes-labels-through"/imm32 + 68/push "ab: # cd"/imm32 + 68/push _test-stream/imm32 + # . . call + e8/call check-stream-equal/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP + # . epilog + 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP + 5d/pop-to-EBP + c3/return + # (re)compute the bounds of the next word in the line next-word: # line : (address stream byte), out : (address slice) # . prolog -- cgit 1.4.1-2-gfad0