about summary refs log tree commit diff stats
path: root/subx/071hex.subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-01-14 17:06:10 -0800
committerKartik Agaram <vc@akkartik.com>2019-01-14 17:06:10 -0800
commit509f0a12ca3d2061b1555ded31dead23f00ed854 (patch)
tree16b0ba9c2318b00be27feb8c155d5e724d7485e0 /subx/071hex.subx
parentfeec2292b5926872de8455d079b92e560a484a7f (diff)
downloadmu-509f0a12ca3d2061b1555ded31dead23f00ed854.tar.gz
4926
Diffstat (limited to 'subx/071hex.subx')
-rw-r--r--subx/071hex.subx74
1 files changed, 70 insertions, 4 deletions
diff --git a/subx/071hex.subx b/subx/071hex.subx
index 173c3dad..8c46ac49 100644
--- a/subx/071hex.subx
+++ b/subx/071hex.subx
@@ -410,6 +410,64 @@ test-parse-hex-int-0x-prefix:
     5d/pop-to-EBP
     c3/return
 
+test-parse-hex-int-zero:
+    # . prolog
+    55/push-EBP
+    89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
+    # var slice/ECX = "0"
+    68/push  _test-slice-hex-int-zero-end/imm32
+    68/push  _test-slice-hex-int-zero/imm32
+    89/copy                         3/mod/direct    1/rm32/ECX    .           .             .           4/r32/ESP   .               .                 # copy ESP to ECX
+    # EAX = parse-hex-int(slice)
+    # . . push args
+    51/push-ECX
+    # . . call
+    e8/call  parse-hex-int/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  0/imm32
+    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-parse-hex-int-0-prefix:
+    # . prolog
+    55/push-EBP
+    89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
+    # var slice/ECX = "03"
+    68/push  _test-slice-hex-int-with-0-prefix-end/imm32
+    68/push  _test-slice-hex-int-with-0-prefix/imm32
+    89/copy                         3/mod/direct    1/rm32/ECX    .           .             .           4/r32/ESP   .               .                 # copy ESP to ECX
+    # EAX = parse-hex-int(slice)
+    # . . push args
+    51/push-ECX
+    # . . call
+    e8/call  parse-hex-int/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  0x3/imm32
+    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
+
 is-hex-digit?:  # c : byte -> bool/EAX
     # . prolog
     55/push-EBP
@@ -591,10 +649,6 @@ _test-slice-hex-int:
   33/3 34/4
 _test-slice-hex-int-end:
 
-_test-slice-hex-int-with-0x-prefix:
-  30/0 78/x 33/3 34/4
-_test-slice-hex-int-with-0x-prefix-end:
-
 _test-slice-hex-int-letters:
   33/3 34/4 61/a
 _test-slice-hex-int-letters-end:
@@ -611,4 +665,16 @@ _test-slice-digits-and-char:
   33/3 34/4 71/q
 _test-slice-digits-and-char-end:
 
+_test-slice-hex-int-with-0x-prefix:
+  30/0 78/x 33/3 34/4
+_test-slice-hex-int-with-0x-prefix-end:
+
+_test-slice-hex-int-zero:
+  30/0
+_test-slice-hex-int-zero-end:
+
+_test-slice-hex-int-with-0-prefix:
+  30/0 33/3
+_test-slice-hex-int-with-0-prefix-end:
+
 # . . vim:nowrap:textwidth=0