From d5171ad7feaa153eaea25f959919258393bd99dc Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Wed, 11 Mar 2020 21:34:49 -0700 Subject: 6130 --- html/apps/factorial.mu.html | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'html/apps/factorial.mu.html') diff --git a/html/apps/factorial.mu.html b/html/apps/factorial.mu.html index c118171c..fa2ce7a3 100644 --- a/html/apps/factorial.mu.html +++ b/html/apps/factorial.mu.html @@ -61,7 +61,7 @@ if ('onhashchange' in window) { 3 # ./a.elf test # to run tests 4 # ./a.elf # to run factorial(5) 5 - 6 fn factorial n: int -> result/eax: int { + 6 fn factorial n: int -> result/eax: int { 7 compare n 1 8 { 9 break-if-> @@ -71,13 +71,13 @@ if ('onhashchange' in window) { 13 break-if-<= 14 var tmp/ecx: int <- copy n 15 tmp <- decrement -16 result <- factorial tmp +16 result <- factorial tmp 17 result <- multiply n 18 } 19 } 20 -21 fn test-factorial { -22 var result/eax: int <- factorial 5 +21 fn test-factorial { +22 var result/eax: int <- factorial 5 23 check-ints-equal result 0x78 "F - test-factorial" 24 } 25 @@ -89,22 +89,21 @@ if ('onhashchange' in window) { 31 # if (len(args) == 1) factorial(5) 32 { 33 break-if-!= -34 var tmp/eax: int <- factorial 5 +34 var tmp/eax: int <- factorial 5 35 exit-status <- copy tmp 36 break $main-body 37 } 38 # if (args[1] == "test") run-tests() -39 var tmp2/ecx: int <- copy 1 # we need this just because we don't yet support `index` on literals; requires some translation-time computation -40 var tmp3/ecx: (addr kernel-string) <- index a, tmp2 -41 var tmp4/eax: boolean <- kernel-string-equal? *tmp3, "test" -42 compare tmp4, 0 -43 { -44 break-if-= -45 run-tests -46 exit-status <- copy 0 # TODO: get at Num-test-failures somehow -47 } -48 } -49 } +39 var tmp2/ecx: (addr kernel-string) <- index a, 1 +40 var tmp3/eax: boolean <- kernel-string-equal? *tmp2, "test" +41 compare tmp3, 0 +42 { +43 break-if-= +44 run-tests +45 exit-status <- copy 0 # TODO: get at Num-test-failures somehow +46 } +47 } +48 } -- cgit 1.4.1-2-gfad0