diff options
author | Kartik Agaram <vc@akkartik.com> | 2019-07-08 00:08:17 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2019-07-08 00:08:17 -0700 |
commit | 7ba3337baee629f4490a292b6f74286a52ecda4e (patch) | |
tree | d2daca8eac2cc0a9abb9a05440bc402c9daf9d9e | |
parent | 6a9d56ff5dbbf6f77d5056e132724968f4129b80 (diff) | |
download | mu-7ba3337baee629f4490a292b6f74286a52ecda4e.tar.gz |
.
move a function around
-rw-r--r-- | subx/apps/subx-common.subx | 120 |
1 files changed, 60 insertions, 60 deletions
diff --git a/subx/apps/subx-common.subx b/subx/apps/subx-common.subx index 4fc200a8..d4b8d0d4 100644 --- a/subx/apps/subx-common.subx +++ b/subx/apps/subx-common.subx @@ -1207,6 +1207,66 @@ $compute-width:end: 5d/pop-to-EBP c3/return +compute-width-of-slice: # s : (address slice) -> EAX : int + # . 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 = s + 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 1/r32/ECX 8/disp8 . # copy *(EBP+8) to ECX + # if has-metadata?(word, "imm32") or has-metadata?(word, "disp32"): return 4 + # . EAX = has-metadata?(word, "imm32") + 68/push "imm32"/imm32 + 51/push-ECX + e8/call has-metadata?/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # . if EAX: return 4 + 3d/compare-EAX-and 1/imm32 + b8/copy-to-EAX 4/imm32 # ZF is set, so we can overwrite EAX now + 74/jump-if-equal $compute-width-of-slice:end/disp8 + # . has-metadata?(word, "disp32") + 68/push "disp32"/imm32 + 51/push-ECX + e8/call has-metadata?/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # . if EAX: return 4 + 3d/compare-EAX-and 1/imm32 + b8/copy-to-EAX 4/imm32 # ZF is set, so we can overwrite EAX now + 74/jump-if-equal $compute-width-of-slice:end/disp8 + # if has-metadata?(word, "imm16") or has-metadata?(word, "disp16"): return 2 + # . has-metadata?(word, "imm16") + 68/push "imm16"/imm32 + 51/push-ECX + e8/call has-metadata?/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # . if EAX: return 2 + 3d/compare-EAX-and 1/imm32 + b8/copy-to-EAX 2/imm32 # ZF is set, so we can overwrite EAX now + 74/jump-if-equal $compute-width-of-slice:end/disp8 + # . has-metadata?(word, "disp16") + 68/push "disp16"/imm32 + 51/push-ECX + e8/call has-metadata?/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # . if EAX: return 2 + 3d/compare-EAX-and 1/imm32 + b8/copy-to-EAX 2/imm32 # ZF is set, so we can overwrite EAX now + 74/jump-if-equal $compute-width-of-slice:end/disp8 + # else: return 1 + b8/copy-to-EAX 1/imm32 +$compute-width-of-slice: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-compute-width: # . prolog 55/push-EBP @@ -1307,66 +1367,6 @@ $test-compute-width:no-metadata: 5d/pop-to-EBP c3/return -compute-width-of-slice: # s : (address slice) -> EAX : int - # . 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 = s - 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 1/r32/ECX 8/disp8 . # copy *(EBP+8) to ECX - # if has-metadata?(word, "imm32") or has-metadata?(word, "disp32"): return 4 - # . EAX = has-metadata?(word, "imm32") - 68/push "imm32"/imm32 - 51/push-ECX - e8/call has-metadata?/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . if EAX: return 4 - 3d/compare-EAX-and 1/imm32 - b8/copy-to-EAX 4/imm32 # ZF is set, so we can overwrite EAX now - 74/jump-if-equal $compute-width-of-slice:end/disp8 - # . has-metadata?(word, "disp32") - 68/push "disp32"/imm32 - 51/push-ECX - e8/call has-metadata?/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . if EAX: return 4 - 3d/compare-EAX-and 1/imm32 - b8/copy-to-EAX 4/imm32 # ZF is set, so we can overwrite EAX now - 74/jump-if-equal $compute-width-of-slice:end/disp8 - # if has-metadata?(word, "imm16") or has-metadata?(word, "disp16"): return 2 - # . has-metadata?(word, "imm16") - 68/push "imm16"/imm32 - 51/push-ECX - e8/call has-metadata?/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . if EAX: return 2 - 3d/compare-EAX-and 1/imm32 - b8/copy-to-EAX 2/imm32 # ZF is set, so we can overwrite EAX now - 74/jump-if-equal $compute-width-of-slice:end/disp8 - # . has-metadata?(word, "disp16") - 68/push "disp16"/imm32 - 51/push-ECX - e8/call has-metadata?/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . if EAX: return 2 - 3d/compare-EAX-and 1/imm32 - b8/copy-to-EAX 2/imm32 # ZF is set, so we can overwrite EAX now - 74/jump-if-equal $compute-width-of-slice:end/disp8 - # else: return 1 - b8/copy-to-EAX 1/imm32 -$compute-width-of-slice: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 - is-label?: # word : (address slice) -> EAX : boolean # . prolog 55/push-EBP |