about summary refs log tree commit diff stats
path: root/apps/survey.subx
diff options
context:
space:
mode:
Diffstat (limited to 'apps/survey.subx')
-rw-r--r--apps/survey.subx22
1 files changed, 12 insertions, 10 deletions
diff --git a/apps/survey.subx b/apps/survey.subx
index aabd1cfa..e19befc2 100644
--- a/apps/survey.subx
+++ b/apps/survey.subx
@@ -41,7 +41,10 @@
 # . 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:
+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
+
     # Heap = new-segment(Heap-size)
     # . . push args
     68/push  Heap/imm32
@@ -58,14 +61,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
     # - 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)
@@ -73,11 +74,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: