diff options
author | Kartik Agaram <vc@akkartik.com> | 2019-02-01 23:49:41 -0800 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2019-02-01 23:49:41 -0800 |
commit | 0ad068dd1da3d463f71c4b63028278767d62af9c (patch) | |
tree | e324febecd92e3f79a2c43f364999d5e236ffafa /subx | |
parent | 070659f9173f547011771ee73633904227e1828a (diff) | |
download | mu-0ad068dd1da3d463f71c4b63028278767d62af9c.tar.gz |
4945
Diffstat (limited to 'subx')
-rw-r--r-- | subx/063hex.subx | 70 | ||||
-rwxr-xr-x | subx/apps/crenshaw2-1 | bin | 15310 -> 15531 bytes | |||
-rwxr-xr-x | subx/apps/crenshaw2-1b | bin | 15869 -> 16090 bytes | |||
-rwxr-xr-x | subx/apps/factorial | bin | 14228 -> 14449 bytes | |||
-rwxr-xr-x | subx/apps/handle | bin | 15021 -> 15242 bytes | |||
-rwxr-xr-x | subx/apps/hex | bin | 18289 -> 18510 bytes | |||
-rwxr-xr-x | subx/apps/pack | bin | 16082 -> 16303 bytes |
7 files changed, 70 insertions, 0 deletions
diff --git a/subx/063hex.subx b/subx/063hex.subx index 7d753f92..6ba2ef7e 100644 --- a/subx/063hex.subx +++ b/subx/063hex.subx @@ -31,6 +31,14 @@ is-hex-int?: # in : (address slice) -> EAX : boolean b8/copy-to-EAX 0/imm32/false 39/compare 3/mod/direct 1/rm32/ECX . . . 2/r32/EDX . . # compare ECX with EDX 7d/jump-if-greater-or-equal $is-hex-int?:end/disp8 + # skip past leading '-' + # . if (*curr == '-') ++curr + 31/xor 3/mod/direct 3/rm32/EBX . . . 3/r32/EBX . . # clear EBX + 8a/copy-byte 0/mod/indirect 1/rm32/ECX . . . 3/r32/BL . . # copy byte at *ECX to BL + 81 7/subop/compare 3/mod/direct 3/rm32/EBX . . . . . 0x2d/imm32/- # compare EBX + 75/jump-if-not-equal $is-hex-int?:initial-0/disp8 + # . ++curr + 41/increment-ECX # skip past leading '0x' $is-hex-int?:initial-0: # . if (*curr != '0') jump to loop @@ -257,6 +265,64 @@ test-is-hex-int-handles-0x-prefix: 5d/pop-to-EBP c3/return +test-is-hex-int-handles-negative: + # . prolog + 55/push-EBP + 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP + # var slice/ECX = "-34a" + 68/push _test-slice-hex-int-letters-end/imm32 + 68/push _test-slice-hex-int-letters-negative/imm32 + 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . . # copy ESP to ECX + # EAX = is-hex-int?(slice) + # . . push args + 51/push-ECX + # . . call + e8/call is-hex-int?/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-hex-int-handles-negative"/imm32 + 68/push 1/imm32/true + 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 + +test-is-hex-int-handles-negative-0x-prefix: + # . prolog + 55/push-EBP + 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP + # var slice/ECX = "-0x3a" + 68/push _test-slice-hex-int-with-0x-prefix-end/imm32 + 68/push _test-slice-hex-int-with-0x-prefix-negative/imm32 + 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . . # copy ESP to ECX + # EAX = is-hex-int?(slice) + # . . push args + 51/push-ECX + # . . call + e8/call is-hex-int?/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-hex-int-handles-negative-0x-prefix"/imm32 + 68/push 1/imm32/true + 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 + parse-hex-int: # in : (address slice) -> result/EAX # . prolog 55/push-EBP @@ -704,6 +770,8 @@ _test-slice-hex-int: 33/3 34/4 _test-slice-hex-int-end: +_test-slice-hex-int-letters-negative: + 2d/- _test-slice-hex-int-letters: 33/3 34/4 61/a _test-slice-hex-int-letters-end: @@ -720,6 +788,8 @@ _test-slice-digits-and-char: 33/3 34/4 71/q _test-slice-digits-and-char-end: +_test-slice-hex-int-with-0x-prefix-negative: + 2d/- _test-slice-hex-int-with-0x-prefix: 30/0 78/x 33/3 34/4 _test-slice-hex-int-with-0x-prefix-end: diff --git a/subx/apps/crenshaw2-1 b/subx/apps/crenshaw2-1 index c21bdb6b..3e694fa1 100755 --- a/subx/apps/crenshaw2-1 +++ b/subx/apps/crenshaw2-1 Binary files differdiff --git a/subx/apps/crenshaw2-1b b/subx/apps/crenshaw2-1b index b8408351..6e26f2c6 100755 --- a/subx/apps/crenshaw2-1b +++ b/subx/apps/crenshaw2-1b Binary files differdiff --git a/subx/apps/factorial b/subx/apps/factorial index 83af72ba..52b8787d 100755 --- a/subx/apps/factorial +++ b/subx/apps/factorial Binary files differdiff --git a/subx/apps/handle b/subx/apps/handle index 3d3e555d..60337c7e 100755 --- a/subx/apps/handle +++ b/subx/apps/handle Binary files differdiff --git a/subx/apps/hex b/subx/apps/hex index c7460132..56f7471b 100755 --- a/subx/apps/hex +++ b/subx/apps/hex Binary files differdiff --git a/subx/apps/pack b/subx/apps/pack index a12b6458..162559e0 100755 --- a/subx/apps/pack +++ b/subx/apps/pack Binary files differ |