diff options
Diffstat (limited to '067parse-hex.subx')
-rw-r--r-- | 067parse-hex.subx | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/067parse-hex.subx b/067parse-hex.subx index 6573b358..fde26e39 100644 --- a/067parse-hex.subx +++ b/067parse-hex.subx @@ -23,13 +23,13 @@ is-hex-int?: # in : (addr slice) -> eax : boolean # if s is empty return false b8/copy-to-eax 0/imm32/false 39/compare 3/mod/direct 1/rm32/ecx . . . 2/r32/edx . . # compare ecx with edx - 73/jump-if-greater-or-equal-unsigned $is-hex-int?:end/disp8 + 73/jump-if-addr>= $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 + 75/jump-if-!= $is-hex-int?:initial-0/disp8 # . ++curr 41/increment-ecx # skip past leading '0x' @@ -38,24 +38,24 @@ $is-hex-int?:initial-0: 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 . . . . . 0x30/imm32/0 # compare ebx - 75/jump-if-not-equal $is-hex-int?:loop/disp8 + 75/jump-if-!= $is-hex-int?:loop/disp8 # . ++curr 41/increment-ecx $is-hex-int?:initial-0x: # . if (curr >= in->end) return true 39/compare 3/mod/direct 1/rm32/ecx . . . 2/r32/edx . . # compare ecx with edx - 73/jump-if-greater-or-equal-unsigned $is-hex-int?:true/disp8 + 73/jump-if-addr>= $is-hex-int?:true/disp8 # . if (*curr != 'x') jump to loop # the previous '0' is still valid so doesn't need to be checked again 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 . . . . . 0x78/imm32/x # compare ebx - 75/jump-if-not-equal $is-hex-int?:loop/disp8 + 75/jump-if-!= $is-hex-int?:loop/disp8 # . ++curr 41/increment-ecx $is-hex-int?:loop: # if (curr >= in->end) return true 39/compare 3/mod/direct 1/rm32/ecx . . . 2/r32/edx . . # compare ecx with edx - 73/jump-if-greater-or-equal-unsigned $is-hex-int?:true/disp8 + 73/jump-if-addr>= $is-hex-int?:true/disp8 # var eax : boolean = is-hex-digit?(*curr) # . . push args 8a/copy-byte 0/mod/indirect 1/rm32/ecx . . . 0/r32/AL . . # copy byte at *ecx to AL @@ -66,7 +66,7 @@ $is-hex-int?:loop: 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp # if (eax == false) return false 3d/compare-eax-and 0/imm32 - 74/jump-if-equal $is-hex-int?:end/disp8 + 74/jump-if-= $is-hex-int?:end/disp8 # ++curr 41/increment-ecx # loop @@ -375,7 +375,7 @@ $parse-hex-int:negative: 31/xor 3/mod/direct 0/rm32/eax . . . 0/r32/eax . . # clear eax 8a/copy-byte 0/mod/indirect 1/rm32/ecx . . . 0/r32/AL . . # copy byte at *ecx to AL 3d/compare-eax-and 0x2d/imm32/- - 75/jump-if-not-equal $parse-hex-int:initial-0/disp8 + 75/jump-if-!= $parse-hex-int:initial-0/disp8 # . ++curr 41/increment-ecx # . negate = true @@ -385,24 +385,24 @@ $parse-hex-int:initial-0: # . if (*curr != '0') jump to loop 8a/copy-byte 0/mod/indirect 1/rm32/ecx . . . 0/r32/AL . . # copy byte at *ecx to AL 3d/compare-eax-and 0x30/imm32/0 - 75/jump-if-not-equal $parse-hex-int:loop/disp8 + 75/jump-if-!= $parse-hex-int:loop/disp8 # . ++curr 41/increment-ecx $parse-hex-int:initial-0x: # . if (curr >= in->end) return result 39/compare 3/mod/direct 1/rm32/ecx . . . 2/r32/edx . . # compare ecx with edx - 73/jump-if-greater-or-equal-unsigned $parse-hex-int:end/disp8 + 73/jump-if-addr>= $parse-hex-int:end/disp8 # . if (*curr != 'x') jump to loop # the previous '0' is still valid so doesn't need to be checked again 31/xor 3/mod/direct 0/rm32/eax . . . 0/r32/eax . . # clear eax 8a/copy-byte 0/mod/indirect 1/rm32/ecx . . . 0/r32/AL . . # copy byte at *ecx to AL 3d/compare-eax-and 0x78/imm32/x - 75/jump-if-not-equal $parse-hex-int:loop/disp8 + 75/jump-if-!= $parse-hex-int:loop/disp8 # . ++curr 41/increment-ecx $parse-hex-int:loop: # if (curr >= in->end) break 39/compare 3/mod/direct 1/rm32/ecx . . . 2/r32/edx . . # compare ecx with edx - 73/jump-if-greater-or-equal-unsigned $parse-hex-int:negate/disp8 + 73/jump-if-addr>= $parse-hex-int:negate/disp8 # var eax : int = from-hex-char(*curr) # . . copy arg to eax 8a/copy-byte 0/mod/indirect 1/rm32/ecx . . . 0/r32/AL . . # copy byte at *ecx to AL @@ -418,7 +418,7 @@ $parse-hex-int:loop: $parse-hex-int:negate: # if (negate?) result = -result 81 7/subop/compare 3/mod/direct 6/rm32/esi . . . . . 0/imm32/false # compare esi - 74/jump-if-equal $parse-hex-int:end/disp8 + 74/jump-if-= $parse-hex-int:end/disp8 f7 3/subop/negate 3/mod/direct 3/rm32/ebx . . . . . . # negate ebx $parse-hex-int:end: # return result @@ -647,18 +647,18 @@ is-hex-digit?: # c : byte -> eax : boolean 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 1/r32/ecx 8/disp8 . # copy *(ebp+8) to ecx # return false if c < '0' 81 7/subop/compare 3/mod/direct 1/rm32/ecx . . . . . 0x30/imm32 # compare ecx - 7c/jump-if-lesser $is-hex-digit?:false/disp8 + 7c/jump-if-< $is-hex-digit?:false/disp8 # return true if c <= '9' 81 7/subop/compare 3/mod/direct 1/rm32/ecx . . . . . 0x39/imm32 # compare ecx - 7e/jump-if-lesser-or-equal $is-hex-digit?:true/disp8 + 7e/jump-if-<= $is-hex-digit?:true/disp8 # drop case 25/and-eax-with 0x5f/imm32 # return false if c > 'f' 81 7/subop/compare 3/mod/direct 1/rm32/ecx . . . . . 0x66/imm32 # compare ecx - 7f/jump-if-greater $is-hex-digit?:false/disp8 + 7f/jump-if-> $is-hex-digit?:false/disp8 # return true if c >= 'a' 81 7/subop/compare 3/mod/direct 1/rm32/ecx . . . . . 0x61/imm32 # compare ecx - 7d/jump-if-greater-or-equal $is-hex-digit?:true/disp8 + 7d/jump-if->= $is-hex-digit?:true/disp8 # otherwise return false $is-hex-digit?:false: b8/copy-to-eax 0/imm32/false @@ -804,15 +804,15 @@ from-hex-char: # in/eax : byte -> out/eax : nibble $from-hex-char:check0: # if (eax < '0') goto abort 3d/compare-eax-with 0x30/imm32/0 - 7c/jump-if-lesser $from-hex-char:abort/disp8 + 7c/jump-if-< $from-hex-char:abort/disp8 $from-hex-char:check1: # if (eax > 'f') goto abort 3d/compare-eax-with 0x66/imm32/f - 7f/jump-if-greater $from-hex-char:abort/disp8 + 7f/jump-if-> $from-hex-char:abort/disp8 $from-hex-char:check2: # if (eax > '9') goto next check 3d/compare-eax-with 0x39/imm32/9 - 7f/jump-if-greater $from-hex-char:check3/disp8 + 7f/jump-if-> $from-hex-char:check3/disp8 $from-hex-char:digit: # return eax - '0' 2d/subtract-from-eax 0x30/imm32/0 @@ -820,7 +820,7 @@ $from-hex-char:digit: $from-hex-char:check3: # if (eax < 'a') goto abort 3d/compare-eax-with 0x61/imm32/a - 7c/jump-if-lesser $from-hex-char:abort/disp8 + 7c/jump-if-< $from-hex-char:abort/disp8 $from-hex-char:letter: # return eax - ('a'-10) 2d/subtract-from-eax 0x57/imm32/a-10 |