From c38b36e2605afd6ce11545d981f9471e0bc8a7c0 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sun, 7 Jul 2019 22:49:04 -0700 Subject: move `is-label?` to `subx-common` --- subx/apps/assort | Bin 28463 -> 28699 bytes subx/apps/crenshaw2-1 | Bin 23307 -> 23337 bytes subx/apps/crenshaw2-1b | Bin 23866 -> 23896 bytes subx/apps/dquotes | Bin 34772 -> 35008 bytes subx/apps/factorial | Bin 22223 -> 22253 bytes subx/apps/handle | Bin 23082 -> 23112 bytes subx/apps/hex | Bin 26316 -> 26346 bytes subx/apps/pack | Bin 43377 -> 43613 bytes subx/apps/subx-common.subx | 83 +++++++++++++++++++++++++++++++++++++++++++++ subx/apps/survey | Bin 32924 -> 32117 bytes subx/apps/survey.subx | 83 --------------------------------------------- 11 files changed, 83 insertions(+), 83 deletions(-) diff --git a/subx/apps/assort b/subx/apps/assort index 9d27fd9a..95ffad2e 100755 Binary files a/subx/apps/assort and b/subx/apps/assort differ diff --git a/subx/apps/crenshaw2-1 b/subx/apps/crenshaw2-1 index 159ed81a..f25d054c 100755 Binary files a/subx/apps/crenshaw2-1 and b/subx/apps/crenshaw2-1 differ diff --git a/subx/apps/crenshaw2-1b b/subx/apps/crenshaw2-1b index f4e02da6..720eef0d 100755 Binary files a/subx/apps/crenshaw2-1b and b/subx/apps/crenshaw2-1b differ diff --git a/subx/apps/dquotes b/subx/apps/dquotes index 6774b8df..8e373c03 100755 Binary files a/subx/apps/dquotes and b/subx/apps/dquotes differ diff --git a/subx/apps/factorial b/subx/apps/factorial index 0f913091..dc637731 100755 Binary files a/subx/apps/factorial and b/subx/apps/factorial differ diff --git a/subx/apps/handle b/subx/apps/handle index c7110e42..16041394 100755 Binary files a/subx/apps/handle and b/subx/apps/handle differ diff --git a/subx/apps/hex b/subx/apps/hex index 5d663c6d..db95f583 100755 Binary files a/subx/apps/hex and b/subx/apps/hex differ diff --git a/subx/apps/pack b/subx/apps/pack index ad55fb75..9d492d15 100755 Binary files a/subx/apps/pack and b/subx/apps/pack differ diff --git a/subx/apps/subx-common.subx b/subx/apps/subx-common.subx index 1dac1c31..8088733f 100644 --- a/subx/apps/subx-common.subx +++ b/subx/apps/subx-common.subx @@ -1322,6 +1322,81 @@ $test-compute-width:no-metadata: 5d/pop-to-EBP c3/return +is-label?: # word : (address slice) -> EAX : boolean + # . prolog + 55/push-EBP + 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP + # . save registers + 51/push-ECX + # ECX = word + 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 1/r32/ECX 8/disp8 . # copy *(EBP+8) to ECX + # ECX = word->end + 8b/copy 1/mod/*+disp8 1/rm32/ECX . . . 1/r32/ECX 4/disp8 . # copy *(ECX+4) to ECX + # *(word->end - 1) == ':' + # . EAX = 0 + 31/xor 3/mod/direct 0/rm32/EAX . . . 0/r32/EAX . . # clear EAX + # . EAX = *((char *) word->end - 1) + 8a/copy-byte 1/mod/*+disp8 1/rm32/ECX . . . 0/r32/AL -1/disp8 . # copy byte at *(ECX-1) to AL + # . (word->end - 1)/EAX == ':' + 3d/compare-EAX-and 3A/imm32/colon + b8/copy-to-EAX 1/imm32/true + 74/jump-if-equal $is-label?:end/disp8 + b8/copy-to-EAX 0/imm32/false +$is-label?:end: + # . restore registers + 59/pop-to-ECX + # . epilog + 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP + 5d/pop-to-EBP + c3/return + +test-is-label?: + # . prolog + 55/push-EBP + 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP +$test-is-label?:true: + # var slice/ECX = slice("AAA:") + 68/push _test-label-slice-end1/imm32 + 68/push _test-label-slice-start/imm32 + 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . . # copy ESP to ECX + # is-label?(slice/ECX) + 51/push-ECX + e8/call is-label?/disp32 + # . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + # check-ints-equal(EAX, 1, msg) + # . . push args + 68/push "F - test-is-label?:true"/imm32 + 68/push 1/imm32 + 50/push-EAX + # . . call + e8/call check-ints-equal/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP +$test-is-label?:false: + # var slice/ECX = slice("AAA") + 68/push _test-label-slice-end2/imm32 + 68/push _test-label-slice-start/imm32 + 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . . # copy ESP to ECX + # is-label?(slice/ECX) + 51/push-ECX + e8/call is-label?/disp32 + # . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + # check-ints-equal(EAX, 0, msg) + # . . push args + 68/push "F - test-is-label?:false"/imm32 + 68/push 0/imm32 + 50/push-EAX + # . . call + e8/call check-ints-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 + == data _test-input-stream: @@ -1408,4 +1483,12 @@ _test-data-segment: 64/d 61/a 74/t 61/a _test-data-segment-end: +_test-label-slice-start: + 41/A + 41/A + 41/A +_test-label-slice-end2: + 3A/: +_test-label-slice-end1: + # . . vim:nowrap:textwidth=0 diff --git a/subx/apps/survey b/subx/apps/survey index 01107cf8..03dcb50e 100755 Binary files a/subx/apps/survey and b/subx/apps/survey differ diff --git a/subx/apps/survey.subx b/subx/apps/survey.subx index cdc55995..5af21261 100644 --- a/subx/apps/survey.subx +++ b/subx/apps/survey.subx @@ -317,81 +317,6 @@ test-convert-computes-addresses: 5d/pop-to-EBP c3/return -is-label?: # word : (address slice) -> EAX : boolean - # . prolog - 55/push-EBP - 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP - # . save registers - 51/push-ECX - # ECX = word - 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 1/r32/ECX 8/disp8 . # copy *(EBP+8) to ECX - # ECX = word->end - 8b/copy 1/mod/*+disp8 1/rm32/ECX . . . 1/r32/ECX 4/disp8 . # copy *(ECX+4) to ECX - # *(word->end - 1) == ':' - # . EAX = 0 - 31/xor 3/mod/direct 0/rm32/EAX . . . 0/r32/EAX . . # clear EAX - # . EAX = *((char *) word->end - 1) - 8a/copy-byte 1/mod/*+disp8 1/rm32/ECX . . . 0/r32/AL -1/disp8 . # copy byte at *(ECX-1) to AL - # . (word->end - 1)/EAX == ':' - 3d/compare-EAX-and 3A/imm32/colon - b8/copy-to-EAX 1/imm32/true - 74/jump-if-equal $is-label?:end/disp8 - b8/copy-to-EAX 0/imm32/false -$is-label?:end: - # . restore registers - 59/pop-to-ECX - # . epilog - 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP - 5d/pop-to-EBP - c3/return - -test-is-label?: - # . prolog - 55/push-EBP - 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP -$test-is-label?:true: - # var slice/ECX = slice("AAA:") - 68/push _test-label-slice-end1/imm32 - 68/push _test-label-slice-start/imm32 - 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . . # copy ESP to ECX - # is-label?(slice/ECX) - 51/push-ECX - e8/call is-label?/disp32 - # . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - # check-ints-equal(EAX, 1, msg) - # . . push args - 68/push "F - test-is-label?:true"/imm32 - 68/push 1/imm32 - 50/push-EAX - # . . call - e8/call check-ints-equal/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP -$test-is-label?:false: - # var slice/ECX = slice("AAA") - 68/push _test-label-slice-end2/imm32 - 68/push _test-label-slice-start/imm32 - 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . . # copy ESP to ECX - # is-label?(slice/ECX) - 51/push-ECX - e8/call is-label?/disp32 - # . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - # check-ints-equal(EAX, 0, msg) - # . . push args - 68/push "F - test-is-label?:false"/imm32 - 68/push 0/imm32 - 50/push-EAX - # . . call - e8/call check-ints-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 - compute-offsets: # in : (address buffered-file), segments : (address stream {string, segment-info}), labels : (address stream {string, label-info}) # pseudocode: # var curr-segment-name = 0 @@ -2279,12 +2204,4 @@ compute-offsets:word-slice:end: 0/imm32/end compute-offsets:heap: 0/imm32/start compute-offsets:heap:end: 0/imm32/end -_test-label-slice-start: - 41/A - 41/A - 41/A -_test-label-slice-end2: - 3A/: -_test-label-slice-end1: - # . . vim:nowrap:textwidth=0 -- cgit 1.4.1-2-gfad0