From c1737cbaae4e0712beff129094aa73d51204f9a7 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Fri, 6 Mar 2020 12:08:42 -0800 Subject: 6083 --- 067parse-hex.subx | 76 +++++++++++++++++++++++++++---------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) (limited to '067parse-hex.subx') diff --git a/067parse-hex.subx b/067parse-hex.subx index 5c8d4334..0524609a 100644 --- a/067parse-hex.subx +++ b/067parse-hex.subx @@ -351,7 +351,7 @@ test-is-hex-int-handles-negative-0x-prefix: 5d/pop-to-ebp c3/return -parse-hex-int: # in: (addr slice) -> result/eax: int +parse-hex-int-from-slice: # in: (addr slice) -> result/eax: int # . prologue 55/push-ebp 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp @@ -370,39 +370,39 @@ parse-hex-int: # in: (addr slice) -> result/eax: int 8b/copy 0/mod/indirect 1/rm32/ecx . . . 1/r32/ecx . . # copy *ecx to ecx # var negate?/esi: boolean = false 31/xor 3/mod/direct 6/rm32/esi . . . 6/r32/esi . . # clear esi -$parse-hex-int:negative: +$parse-hex-int-from-slice:negative: # if (*curr == '-') ++curr, negate = true 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-!= $parse-hex-int:initial-0/disp8 + 75/jump-if-!= $parse-hex-int-from-slice:initial-0/disp8 # . ++curr 41/increment-ecx # . negate = true be/copy-to-esi 1/imm32/true -$parse-hex-int:initial-0: +$parse-hex-int-from-slice:initial-0: # skip past leading '0x' # . 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-!= $parse-hex-int:loop/disp8 + 75/jump-if-!= $parse-hex-int-from-slice:loop/disp8 # . ++curr 41/increment-ecx -$parse-hex-int:initial-0x: +$parse-hex-int-from-slice: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-addr>= $parse-hex-int:end/disp8 + 73/jump-if-addr>= $parse-hex-int-from-slice: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-!= $parse-hex-int:loop/disp8 + 75/jump-if-!= $parse-hex-int-from-slice:loop/disp8 # . ++curr 41/increment-ecx -$parse-hex-int:loop: +$parse-hex-int-from-slice:loop: # if (curr >= in->end) break 39/compare 3/mod/direct 1/rm32/ecx . . . 2/r32/edx . . # compare ecx with edx - 73/jump-if-addr>= $parse-hex-int:negate/disp8 + 73/jump-if-addr>= $parse-hex-int-from-slice: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 @@ -414,13 +414,13 @@ $parse-hex-int:loop: # ++curr 41/increment-ecx # loop - eb/jump $parse-hex-int:loop/disp8 -$parse-hex-int:negate: + eb/jump $parse-hex-int-from-slice:loop/disp8 +$parse-hex-int-from-slice:negate: # if (negate?) result = -result 81 7/subop/compare 3/mod/direct 6/rm32/esi . . . . . 0/imm32/false # compare esi - 74/jump-if-= $parse-hex-int:end/disp8 + 74/jump-if-= $parse-hex-int-from-slice:end/disp8 f7 3/subop/negate 3/mod/direct 3/rm32/ebx . . . . . . # negate ebx -$parse-hex-int:end: +$parse-hex-int-from-slice:end: # return result 89/copy 3/mod/direct 0/rm32/eax . . . 3/r32/ebx . . # copy ebx to eax # . restore registers @@ -433,7 +433,7 @@ $parse-hex-int:end: 5d/pop-to-ebp c3/return -test-parse-hex-int-single-digit: +test-parse-hex-int-from-slice-single-digit: # . prologue 55/push-ebp 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp @@ -446,16 +446,16 @@ test-parse-hex-int-single-digit: 51/push-ecx 50/push-eax 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . . # copy esp to ecx - # eax = parse-hex-int(slice) + # eax = parse-hex-int-from-slice(slice) # . . push args 51/push-ecx # . . call - e8/call parse-hex-int/disp32 + e8/call parse-hex-int-from-slice/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp # check-ints-equal(eax, 0xa, msg) # . . push args - 68/push "F - test-parse-hex-int-single-digit"/imm32 + 68/push "F - test-parse-hex-int-from-slice-single-digit"/imm32 68/push 0xa/imm32 50/push-eax # . . call @@ -467,7 +467,7 @@ test-parse-hex-int-single-digit: 5d/pop-to-ebp c3/return -test-parse-hex-int-multi-digit: +test-parse-hex-int-from-slice-multi-digit: # . prologue 55/push-ebp 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp @@ -480,16 +480,16 @@ test-parse-hex-int-multi-digit: 51/push-ecx 50/push-eax 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . . # copy esp to ecx - # eax = parse-hex-int(slice) + # eax = parse-hex-int-from-slice(slice) # . . push args 51/push-ecx # . . call - e8/call parse-hex-int/disp32 + e8/call parse-hex-int-from-slice/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp # check-ints-equal(eax, 0x34a, msg) # . . push args - 68/push "F - test-parse-hex-int-multi-digit"/imm32 + 68/push "F - test-parse-hex-int-from-slice-multi-digit"/imm32 68/push 0x34a/imm32 50/push-eax # . . call @@ -501,7 +501,7 @@ test-parse-hex-int-multi-digit: 5d/pop-to-ebp c3/return -test-parse-hex-int-0x-prefix: +test-parse-hex-int-from-slice-0x-prefix: # . prologue 55/push-ebp 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp @@ -514,16 +514,16 @@ test-parse-hex-int-0x-prefix: 51/push-ecx 50/push-eax 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . . # copy esp to ecx - # eax = parse-hex-int(slice) + # eax = parse-hex-int-from-slice(slice) # . . push args 51/push-ecx # . . call - e8/call parse-hex-int/disp32 + e8/call parse-hex-int-from-slice/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp # check-ints-equal(eax, 0x34a, msg) # . . push args - 68/push "F - test-parse-hex-int-0x-prefix"/imm32 + 68/push "F - test-parse-hex-int-from-slice-0x-prefix"/imm32 68/push 0x34/imm32 50/push-eax # . . call @@ -535,7 +535,7 @@ test-parse-hex-int-0x-prefix: 5d/pop-to-ebp c3/return -test-parse-hex-int-zero: +test-parse-hex-int-from-slice-zero: # . prologue 55/push-ebp 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp @@ -548,16 +548,16 @@ test-parse-hex-int-zero: 51/push-ecx 50/push-eax 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . . # copy esp to ecx - # eax = parse-hex-int(slice) + # eax = parse-hex-int-from-slice(slice) # . . push args 51/push-ecx # . . call - e8/call parse-hex-int/disp32 + e8/call parse-hex-int-from-slice/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp # check-ints-equal(eax, 0x34a, msg) # . . push args - 68/push "F - test-parse-hex-int-zero"/imm32 + 68/push "F - test-parse-hex-int-from-slice-zero"/imm32 68/push 0/imm32 50/push-eax # . . call @@ -569,7 +569,7 @@ test-parse-hex-int-zero: 5d/pop-to-ebp c3/return -test-parse-hex-int-0-prefix: +test-parse-hex-int-from-slice-0-prefix: # . prologue 55/push-ebp 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp @@ -582,16 +582,16 @@ test-parse-hex-int-0-prefix: 51/push-ecx 50/push-eax 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . . # copy esp to ecx - # eax = parse-hex-int(slice) + # eax = parse-hex-int-from-slice(slice) # . . push args 51/push-ecx # . . call - e8/call parse-hex-int/disp32 + e8/call parse-hex-int-from-slice/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp # check-ints-equal(eax, 0x3, msg) # . . push args - 68/push "F - test-parse-hex-int-0-prefix"/imm32 + 68/push "F - test-parse-hex-int-from-slice-0-prefix"/imm32 68/push 0x3/imm32 50/push-eax # . . call @@ -603,7 +603,7 @@ test-parse-hex-int-0-prefix: 5d/pop-to-ebp c3/return -test-parse-hex-int-negative: +test-parse-hex-int-from-slice-negative: # . prologue 55/push-ebp 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp @@ -616,16 +616,16 @@ test-parse-hex-int-negative: 51/push-ecx 50/push-eax 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . . # copy esp to ecx - # eax = parse-hex-int(slice) + # eax = parse-hex-int-from-slice(slice) # . . push args 51/push-ecx # . . call - e8/call parse-hex-int/disp32 + e8/call parse-hex-int-from-slice/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp # check-ints-equal(eax, -3, msg) # . . push args - 68/push "F - test-parse-hex-int-negative"/imm32 + 68/push "F - test-parse-hex-int-from-slice-negative"/imm32 68/push -3/imm32 50/push-eax # . . call -- cgit 1.4.1-2-gfad0