about summary refs log tree commit diff stats
path: root/apps/hex.subx
diff options
context:
space:
mode:
Diffstat (limited to 'apps/hex.subx')
-rw-r--r--apps/hex.subx19
1 files changed, 11 insertions, 8 deletions
diff --git a/apps/hex.subx b/apps/hex.subx
index be8f9fb5..a28d9461 100644
--- a/apps/hex.subx
+++ b/apps/hex.subx
@@ -18,6 +18,9 @@
 # . 1-3 bytes   3 bits              2 bits          3 bits        3 bits      3 bits        2 bits      2 bits      0/1/2/4 bytes   0/1/2/4 bytes
 
 Entry:  # run tests if necessary, convert stdin if not
+    # . prolog
+    89/copy                         3/mod/direct    5/rm32/ebp    .           .             .           4/r32/esp   .               .                 # copy esp to ebp
+
     # initialize heap
     # . Heap = new-segment(64KB)
     # . . push args
@@ -28,13 +31,12 @@ Entry:  # run tests if necessary, convert stdin if not
     # . . discard args
     81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               8/imm32           # add to esp
 
-    # . prolog
-    89/copy                         3/mod/direct    5/rm32/ebp    .           .             .           4/r32/esp   .               .                 # copy esp to ebp
     # - if argc > 1 and argv[1] == "test", then return run_tests()
-    # . argc > 1
+    # if (argc <= 1) goto run-main
     81          7/subop/compare     1/mod/*+disp8   5/rm32/ebp    .           .             .           .           0/disp8         1/imm32           # compare *ebp
     7e/jump-if-lesser-or-equal  $run-main/disp8
-    # . argv[1] == "test"
+    # if (!kernel-string-equal?(argv[1], "test")) goto run-main
+    # . eax = kernel-string-equal?(argv[1], "test")
     # . . push args
     68/push  "test"/imm32
     ff          6/subop/push        1/mod/*+disp8   5/rm32/ebp    .           .             .           .           8/disp8         .                 # push *(ebp+8)
@@ -42,11 +44,12 @@ Entry:  # run tests if necessary, convert stdin if not
     e8/call  kernel-string-equal?/disp32
     # . . discard args
     81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               8/imm32           # add to esp
-    # . check result
-    3d/compare-eax-and  1/imm32
-    75/jump-if-not-equal  $run-main/disp8
-    # . run-tests()
+    # . if (eax == 0) goto run-main
+    3d/compare-eax-and  0/imm32
+    74/jump-if-equal  $run-main/disp8
+    # run-tests()
     e8/call  run-tests/disp32
+    # return *Num-test-failures
     8b/copy                         0/mod/indirect  5/rm32/.disp32            .             .           3/r32/ebx   Num-test-failures/disp32          # copy *Num-test-failures to ebx
     eb/jump  $main:end/disp8
 $run-main: