From 783eb31a0527677e6c684efc835bd13f9355a2f3 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Mon, 23 Mar 2020 02:16:32 -0700 Subject: 6162 --- html/apps/factorial.mu.html | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'html/apps/factorial.mu.html') diff --git a/html/apps/factorial.mu.html b/html/apps/factorial.mu.html index bb402fdd..7159ab5e 100644 --- a/html/apps/factorial.mu.html +++ b/html/apps/factorial.mu.html @@ -14,11 +14,12 @@ pre { white-space: pre-wrap; font-family: monospace; color: #000000; background- body { font-size:12pt; font-family: monospace; color: #000000; background-color: #c6c6c6; } a { color:inherit; } * { font-size:12pt; font-size: 1em; } +.muFunction { color: #af5f00; text-decoration: underline; } .LineNr { } +.muTest { color: #5f8700; } .Comment { color: #005faf; } .Constant { color: #008787; } .Special { color: #ff6060; } -.Identifier { color: #af5f00; } .Delimiter { color: #c000c0; } .PreProc { color: #c000c0; } --> @@ -69,14 +70,14 @@ if ('onhashchange' in window) { 11 # 12 # Compare apps/factorial4.subx 13 -14 fn factorial n: int -> result/eax: int { +14 fn factorial n: int -> result/eax: int { 15 compare n 1 16 { -17 break-if-> +17 break-if-> 18 result <- copy 1 19 } 20 { -21 break-if-<= +21 break-if-<= 22 var tmp/ecx: int <- copy n 23 tmp <- decrement 24 result <- factorial tmp @@ -84,29 +85,29 @@ if ('onhashchange' in window) { 26 } 27 } 28 -29 fn test-factorial { +29 fn test-factorial { 30 var result/eax: int <- factorial 5 31 check-ints-equal result 0x78 "F - test-factorial" 32 } 33 -34 fn main args: (addr array kernel-string) -> exit-status/ebx: int { -35 var a/eax: (addr array kernel-string) <- copy args +34 fn main args: (addr array string) -> exit-status/ebx: int { +35 var a/eax: (addr array string) <- copy args 36 var tmp/ecx: int <- length a 37 $main-body: { -38 compare tmp, 1 -39 # if (len(args) == 1) factorial(5) +38 # if (len(args) <= 4) factorial(5) +39 compare tmp, 4 40 { -41 break-if-!= +41 break-if-> 42 var tmp/eax: int <- factorial 5 43 exit-status <- copy tmp -44 break $main-body +44 break $main-body 45 } 46 # if (args[1] == "test") run-tests() -47 var tmp2/ecx: (addr kernel-string) <- index a, 1 -48 var tmp3/eax: boolean <- kernel-string-equal? *tmp2, "test" +47 var tmp2/ecx: (addr string) <- index a, 1 +48 var tmp3/eax: boolean <- string-equal? *tmp2, "test" 49 compare tmp3, 0 50 { -51 break-if-= +51 break-if-= 52 run-tests 53 exit-status <- copy 0 # TODO: get at Num-test-failures somehow 54 } -- cgit 1.4.1-2-gfad0