about summary refs log tree commit diff stats
path: root/apps/tests.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/tests.subx
parentf3ab82e9431dd54c7369671232b6841073f1da68 (diff)
downloadmu-282681c729857026e3713d45e9027fdfccda0880.tar.gz
5600
Diffstat (limited to 'apps/tests.subx')
-rw-r--r--apps/tests.subx26
1 files changed, 14 insertions, 12 deletions
diff --git a/apps/tests.subx b/apps/tests.subx
index 99b02664..8f825a3a 100644
--- a/apps/tests.subx
+++ b/apps/tests.subx
@@ -9,8 +9,12 @@
 # . op          subop               mod             rm32          base        index         scale       r32
 # . 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:
-    # Heap = new-segment(Heap-size)
+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
     68/push  Heap/imm32
     68/push  Heap-size/imm32
@@ -26,15 +30,12 @@ Entry:
     # . . discard args
     81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               4/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
-    # initialize heap
     # - 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 +43,12 @@ Entry:
     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: