diff options
Diffstat (limited to 'subx/apps')
-rwxr-xr-x | subx/apps/survey | bin | 23874 -> 26337 bytes | |||
-rw-r--r-- | subx/apps/survey.subx | 234 |
2 files changed, 219 insertions, 15 deletions
diff --git a/subx/apps/survey b/subx/apps/survey index f3079746..fb4d2e2b 100755 --- a/subx/apps/survey +++ b/subx/apps/survey Binary files differdiff --git a/subx/apps/survey.subx b/subx/apps/survey.subx index b6f94fff..adf91ebd 100644 --- a/subx/apps/survey.subx +++ b/subx/apps/survey.subx @@ -110,7 +110,7 @@ $main:end: convert: # in : (address buffered-file), out : (address buffered-file) -> <void> # pseudocode # var segments = new-stream(10 rows, 16 bytes each) - # var labels = new-stream(512 rows, 12 bytes each) + # var labels = new-stream(512 rows, 16 bytes each) # compute-offsets(in, segments, labels) # compute-addresses(segments, labels) # rewind-stream(in) @@ -128,9 +128,9 @@ convert: # in : (address buffered-file), out : (address buffered-file) -> <void 68/push 0/imm32/read 68/push 0/imm32/write 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . . # copy ESP to ECX - # var labels/EDX = stream(512 * 12) - 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 0x1800/imm32 # subtract from ESP - 68/push 0x1800/imm32/length + # var labels/EDX = stream(512 * 16) + 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 0x2000/imm32 # subtract from ESP + 68/push 0x2000/imm32/length 68/push 0/imm32/read 68/push 0/imm32/write 89/copy 3/mod/direct 2/rm32/EDX . . . 4/r32/ESP . . # copy ESP to EDX @@ -279,10 +279,38 @@ test-convert-computes-addresses: # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP # check trace - # . check-trace-contains(Trace-stream, "label 'x' is at address 0x1079") - # . check-trace-contains(Trace-stream, "segment 'code' starts at address 0x74") - # . check-trace-contains(Trace-stream, "segment 'code' has size 0x5") - # . check-trace-contains(Trace-stream, "segment 'data' starts at address 0x1079") + # . check-trace-contains("label 'x' is at address 0x1079", msg) + # . . push args + 68/push "F - test-convert-computes-addresses/0"/imm32 + 68/push "label 'x' is at address 0x1079"/imm32 + # . . call + e8/call check-trace-contains/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # . check-trace-contains("segment 'code' starts at address 0x74", msg) + # . . push args + 68/push "F - test-convert-computes-addresses/1"/imm32 + 68/push "segment 'code' starts at address 0x74"/imm32 + # . . call + e8/call check-trace-contains/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # . check-trace-contains("segment 'code' has size 0x5", msg) + # . . push args + 68/push "F - test-convert-computes-addresses/2"/imm32 + 68/push "segment 'code' has size 0x5"/imm32 + # . . call + e8/call check-trace-contains/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # . check-trace-contains("segment 'data' starts at address 0x1079", msg) + # . . push args + 68/push "F - test-convert-computes-addresses/3"/imm32 + 68/push "segment 'data' starts at address 0x1079"/imm32 + # . . call + e8/call check-trace-contains/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP # . epilog 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP 5d/pop-to-EBP @@ -310,20 +338,164 @@ test-compute-offsets: # ab x/imm32 # == data 0x1000 # x: - # 01 + # 34 # # trace contains (in any order): - # segment 'code' is at file offset 0 - # segment 'code' has size 5 - # segment 'data' is at file offset 5 - # label 'x' is in segment data - # label 'x' is at offset 0 - # segment 'data' has size 1 + # segment 'code' is at file offset 0x0 + # segment 'code' has size 0x5 + # segment 'data' is at file offset 0x5 + # label 'x' is in segment 'data' + # label 'x' is at offset 0x0 + # segment 'data' has size 0x1 # # . prolog 55/push-EBP 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP # setup + # . clear-stream(_test-input-stream) + # . . push args + 68/push _test-input-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-input-buffered-file+4) + # . . push args + b8/copy-to-EAX _test-input-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-output-stream) + # . . push args + 68/push _test-output-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-output-buffered-file+4) + # . . push args + b8/copy-to-EAX _test-output-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 + # var segments/ECX = stream(2 * 16) + 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 0x20/imm32 # subtract from ESP + 68/push 0x20/imm32/length + 68/push 0/imm32/read + 68/push 0/imm32/write + 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . . # copy ESP to ECX + # var labels/EDX = stream(2 * 16) + 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 0x20/imm32 # subtract from ESP + 68/push 0x20/imm32/length + 68/push 0/imm32/read + 68/push 0/imm32/write + 89/copy 3/mod/direct 2/rm32/EDX . . . 4/r32/ESP . . # copy ESP to EDX + # initialize input + # . write(_test-input-stream, "== code 0x1\n") + # . . push args + 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, "ab x/imm32\n") + # . . push args + 68/push "ab x/imm32\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 0x1000\n") + # . . push args + 68/push "== data 0x1000\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, "x:\n") + # . . push args + 68/push "x:\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, "34\n") + # . . push args + 68/push "34\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 + # compute-offsets(_test-input-buffered-file, _test-output-buffered-file, segments, labels) + # . . push args + 52/push-EDX + 51/push-ECX + 68/push _test-output-buffered-file/imm32 + 68/push _test-input-buffered-file/imm32 + # . . call + e8/call compute-offsets/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x10/imm32 # add to ESP + # check trace + # . check-trace-contains("segment 'code' is at file offset 0x0", msg) + # . . push args + 68/push "F - test-compute-offsets/0"/imm32 + 68/push "segment 'code' is at file offset 0x0"/imm32 + # . . call + e8/call check-trace-contains/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # . check-trace-contains("segment 'code' has size 0x5", msg) + # . . push args + 68/push "F - test-compute-offsets/1"/imm32 + 68/push "segment 'code' has size 0x5"/imm32 + # . . call + e8/call check-trace-contains/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # . check-trace-contains("segment 'data' is at file offset 0x5", msg) + # . . push args + 68/push "F - test-compute-offsets/2"/imm32 + 68/push "segment 'data' is at file offset 0x5"/imm32 + # . . call + e8/call check-trace-contains/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # . check-trace-contains("segment 'data' has size 0x1", msg) + # . . push args + 68/push "F - test-compute-offsets/3"/imm32 + 68/push "segment 'data' has size 0x1"/imm32 + # . . call + e8/call check-trace-contains/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # . check-trace-contains("label 'x' is in segment 'data'", msg) + # . . push args + 68/push "F - test-compute-offsets/4"/imm32 + 68/push "label 'x' is in segment 'data'"/imm32 + # . . call + e8/call check-trace-contains/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # . check-trace-contains("label 'x' is at offset 0x0", msg) + # . . push args + 68/push "F - test-compute-offsets/5"/imm32 + 68/push "label 'x' is at offset 0x0"/imm32 + # . . call + e8/call check-trace-contains/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP # . epilog 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP 5d/pop-to-EBP @@ -363,6 +535,38 @@ test-compute-addresses: 55/push-EBP 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP # setup + # . check-trace-contains("segment 'code' starts at address 0x1074", msg) + # . . push args + 68/push "F - test-compute-addresses/0"/imm32 + 68/push "segment 'code' starts at address 0x1074"/imm32 + # . . call + e8/call check-trace-contains/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # . check-trace-contains("segment 'data' starts at address 0x579", msg) + # . . push args + 68/push "F - test-compute-addresses/1"/imm32 + 68/push "segment 'data' starts at address 0x579"/imm32 + # . . call + e8/call check-trace-contains/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # . check-trace-contains("label 'l1' is at address 0x1077", msg) + # . . push args + 68/push "F - test-compute-addresses/2"/imm32 + 68/push "label 'l1' is at address 0x1077"/imm32 + # . . call + e8/call check-trace-contains/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # . check-trace-contains("label 'l2' is at address 0x579", msg) + # . . push args + 68/push "F - test-compute-addresses/3"/imm32 + 68/push "label 'l2' is at address 0x579"/imm32 + # . . call + e8/call check-trace-contains/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP # . epilog 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP 5d/pop-to-EBP |