about summary refs log tree commit diff stats
path: root/apps/sigils.subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-08-31 23:22:49 -0700
committerKartik Agaram <vc@akkartik.com>2019-08-31 23:42:45 -0700
commit282681c729857026e3713d45e9027fdfccda0880 (patch)
tree33b3e0fd15aa70150f88df81edc8d6454814c487 /apps/sigils.subx
parentf3ab82e9431dd54c7369671232b6841073f1da68 (diff)
downloadmu-282681c729857026e3713d45e9027fdfccda0880.tar.gz
5600
Diffstat (limited to 'apps/sigils.subx')
-rw-r--r--apps/sigils.subx20
1 files changed, 11 insertions, 9 deletions
diff --git a/apps/sigils.subx b/apps/sigils.subx
index 934f3be2..53452f1e 100644
--- a/apps/sigils.subx
+++ b/apps/sigils.subx
@@ -46,6 +46,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(Heap-size)
     # . . push args
@@ -56,14 +59,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
 
-    # run tests if necessary, convert stdin if not
-    # . 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)
@@ -71,11 +72,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: