about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-12-09 16:53:57 -0800
committerKartik Agaram <vc@akkartik.com>2019-12-09 16:53:57 -0800
commitef21004a5c5b655b7e352f658a8368986ac1c1df (patch)
tree5c88556ff09014bef796def3200aa79ce0859e28
parentaf1473922226e0ea07e6da9f486634702a6915c1 (diff)
downloadmu-ef21004a5c5b655b7e352f658a8368986ac1c1df.tar.gz
5809
-rw-r--r--apps/factorial2.subx8
-rw-r--r--apps/factorial3.subx6
-rw-r--r--apps/factorial4.subx3
3 files changed, 9 insertions, 8 deletions
diff --git a/apps/factorial2.subx b/apps/factorial2.subx
index ecaccbcf..e512521a 100644
--- a/apps/factorial2.subx
+++ b/apps/factorial2.subx
@@ -45,8 +45,8 @@ Entry:  # run tests if necessary, compute `factorial(5)` if not
     e8/call kernel-string-equal?/disp32
     # . . discard args
     81 0/subop/add %esp 8/imm32
-    # . if (eax == 0) goto run-main
-    3d/compare-eax-and 0/imm32
+    # . if (eax == false) goto run-main
+    3d/compare-eax-and 0/imm32/false
     74/jump-if-equal $run-main/disp8
     # run-tests()
     e8/call run-tests/disp32
@@ -77,10 +77,10 @@ factorial:  # n : int -> int/eax
     b8/copy-to-eax 1/imm32
     81 7/subop/compare *(ebp+8) 1/imm32
     7e/jump-if-<= $factorial:end/disp8
-    # ebx = n-1
+    # var ebx : int = n-1
     8b/-> *(ebp+8) 3/r32/ebx
     4b/decrement-ebx
-    # eax = factorial(n-1)
+    # var eax : int = factorial(n-1)
     # . . push args
     53/push-ebx
     # . . call
diff --git a/apps/factorial3.subx b/apps/factorial3.subx
index 6cfd38c3..7a8cee8c 100644
--- a/apps/factorial3.subx
+++ b/apps/factorial3.subx
@@ -32,8 +32,8 @@ Entry:  # run tests if necessary, compute `factorial(5)` if not
     7e/jump-if-lesser-or-equal $run-main/disp8
     # if (!kernel-string-equal?(argv[1], "test")) goto run-main
     (kernel-string-equal? *(ebp+8) "test")  # => eax
-    # . if (eax == 0) goto run-main
-    3d/compare-eax-and 0/imm32
+    # . if (eax == false) goto run-main
+    3d/compare-eax-and 0/imm32/false
     74/jump-if-equal $run-main/disp8
     #
     (run-tests)
@@ -59,7 +59,7 @@ factorial:  # n : int -> int/eax
     b8/copy-to-eax 1/imm32
     81 7/subop/compare *(ebp+8) 1/imm32
     7e/jump-if-<= $factorial:end/disp8
-    # ebx = n-1
+    # var ebx : int = n-1
     8b/-> *(ebp+8) 3/r32/ebx
     4b/decrement-ebx
     #
diff --git a/apps/factorial4.subx b/apps/factorial4.subx
index 2752dfd0..1881c79d 100644
--- a/apps/factorial4.subx
+++ b/apps/factorial4.subx
@@ -34,7 +34,7 @@ Entry:  # run tests if necessary, compute `factorial(5)` if not
       7e/jump-if-lesser-or-equal break/disp8
       # if (!kernel-string-equal?(argv[1], "test")) break
       (kernel-string-equal? *(ebp+8) "test")  # => eax
-      3d/compare-eax-and 0/imm32
+      3d/compare-eax-and 0/imm32/false
       74/jump-if-equal break/disp8
       #
       (run-tests)
@@ -70,6 +70,7 @@ factorial:  # n : int -> int/eax
     # if (n > 1) return n * factorial(n-1)
     {
       7e/jump-if-lesser-or-equal break/disp8
+      # var ebx : int = n-1
       8b/-> *(ebp+8) 3/r32/ebx
       4b/decrement-ebx
       (factorial %ebx)  # => eax