about summary refs log tree commit diff stats
path: root/067parse-hex.subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-11-28 00:36:58 -0800
committerKartik Agaram <vc@akkartik.com>2019-11-28 00:37:26 -0800
commit3a7da4e735247daaafe0f715bd2de4fb21e44e3d (patch)
tree6ea82a8fade1c070ae3d87a1eade8fa997b2f4ad /067parse-hex.subx
parent0d741834f32b0de538cfabc93a00401382f334d2 (diff)
downloadmu-3a7da4e735247daaafe0f715bd2de4fb21e44e3d.tar.gz
5769 - support uppercase hex in SubX
Diffstat (limited to '067parse-hex.subx')
-rw-r--r--067parse-hex.subx20
1 files changed, 12 insertions, 8 deletions
diff --git a/067parse-hex.subx b/067parse-hex.subx
index 2ba3c740..0695ebeb 100644
--- a/067parse-hex.subx
+++ b/067parse-hex.subx
@@ -644,21 +644,25 @@ is-hex-digit?:  # c : byte -> eax : boolean
     # ecx = c
     8b/copy                         1/mod/*+disp8   5/rm32/ebp    .           .             .           1/r32/ecx   8/disp8         .                 # copy *(ebp+8) to ecx
     # return false if c < '0'
-    b8/copy-to-eax  0/imm32/false
     81          7/subop/compare     3/mod/direct    1/rm32/ecx    .           .             .           .           .               0x30/imm32        # compare ecx
-    7c/jump-if-lesser  $is-hex-digit?:end/disp8
-    # 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?:end/disp8
+    7c/jump-if-lesser  $is-hex-digit?:false/disp8
     # return true if c <= '9'
-    b8/copy-to-eax  1/imm32/true
     81          7/subop/compare     3/mod/direct    1/rm32/ecx    .           .             .           .           .               0x39/imm32        # compare ecx
-    7e/jump-if-lesser-or-equal  $is-hex-digit?:end/disp8
+    7e/jump-if-lesser-or-equal  $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
     # 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?:end/disp8
+    7d/jump-if-greater-or-equal  $is-hex-digit?:true/disp8
+$is-hex-digit?:false:
     # otherwise return false
     b8/copy-to-eax  0/imm32/false
+    eb/jump $is-hex-digit?:end/disp8
+$is-hex-digit?:true:
+    b8/copy-to-eax  1/imm32/true
 $is-hex-digit?:end:
     # . restore registers
     59/pop-to-ecx