diff options
-rw-r--r-- | mu.arc | 12 | ||||
-rw-r--r-- | trace.mu | 18 |
2 files changed, 29 insertions, 1 deletions
diff --git a/mu.arc b/mu.arc index e4f22ce1..72a0d86c 100644 --- a/mu.arc +++ b/mu.arc @@ -3148,6 +3148,15 @@ (reply result:terminal-address) ) +(init-fn divides? + (default-space:space-address <- new space:literal 30:literal/capacity) + (x:integer <- next-input) + (y:integer <- next-input) + (_ remainder:integer <- divide-with-remainder x:integer y:integer) + (result:boolean <- equal remainder:integer 0:literal) + (reply result:boolean) +) + ; after all system software is loaded: ;? (= dump-trace* (obj whitelist '("cn0" "cn1"))) (freeze system-function*) @@ -3186,7 +3195,8 @@ (when (no cdr.argv) (add-code:readfile "trace.mu") (wipe function*!main) - (add-code:readfile "chessboard.mu") + (add-code:readfile "factorial.mu") +;? (add-code:readfile "chessboard.mu") ; takes too long (wipe function*!main) (freeze function*) (load-system-functions) diff --git a/trace.mu b/trace.mu index ad8c306c..b327a1d6 100644 --- a/trace.mu +++ b/trace.mu @@ -22,6 +22,7 @@ ;? ($print (("parse-traces\n" literal))) ;? 2 (in:stream-address <- next-input) ; check input size + ($print (("counting lines\n" literal))) (n:integer <- copy 0:literal) { begin (done?:boolean <- end-of-stream? in:stream-address) @@ -31,6 +32,13 @@ (newline?:boolean <- equal c:character ((#\newline literal))) (break-unless newline?:boolean) (n:integer <- add n:integer 1:literal) + { begin +;? (print?:boolean <- divides? n:integer 100:literal) +;? (break-unless print?:boolean) + ($print ((" " literal))) + ($print n:integer) + ($print (("\n" literal))) + } } (loop) } @@ -42,6 +50,8 @@ (curr-tail:instruction-trace-address <- copy nil:literal) (ch:buffer-address <- init-buffer 5:literal) ; accumulator for traces between instructions (run:string-address/const <- new "run") + ($print (("parsing\n" literal))) + (n:integer <- copy 0:literal) ; reading each line from 'in' { begin next-line @@ -51,6 +61,14 @@ (break-if done?:boolean) ; parse next line as a generic trace (line:string-address <- read-line in:stream-address) + { begin + (n:integer <- add n:integer 1:literal) + (print?:boolean <- divides? n:integer 100:literal) + (break-unless print?:boolean) + ($print ((" " literal))) + ($print n:integer) + ($print (("\n" literal))) + } ;? (print-string nil:literal/terminal line:string-address) ;? 1 (f:trace-address <- parse-trace line:string-address) (l:string-address <- get f:trace-address/deref label:offset) |