From: Tim Vaughan Date: Sat, 23 Apr 2016 11:29:18 +0000 (+1200) Subject: NL only prints "ok" in state 0 X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;h=eb93827226814b2e6fa4ac07abed8ab0b752bca2;p=forth.jl.git NL only prints "ok" in state 0 --- diff --git a/src/forth.jl b/src/forth.jl index 3363ea7..0c9cf4f 100644 --- a/src/forth.jl +++ b/src/forth.jl @@ -784,11 +784,16 @@ end) INTERPRET = defPrim("INTERPRET", () -> begin callPrim(mem[WORD]) + + wordName = getString(mem[reg.PSP-1], mem[reg.PSP]) + println("... ", replace(wordName, "\n", "\\n"), " ...") + callPrim(mem[TWODUP]) callPrim(mem[FIND]) wordAddr = mem[reg.PSP] + if wordAddr>0 # Word in dictionary @@ -811,8 +816,6 @@ INTERPRET = defPrim("INTERPRET", () -> begin popPS() - wordName = getString(mem[reg.PSP-1], mem[reg.PSP]) - callPrim(mem[NUMBER]) if popPS() != 0 @@ -840,7 +843,9 @@ QUIT = defWord("QUIT", BRANCH,-2]) NL = defPrim("\n", () -> begin - println(" ok") + if mem[STATE] == 0 + println(" ok") + end return mem[NEXT] end) @@ -872,7 +877,9 @@ function runVM() # Primitive processing loop. # Everyting else is simply a consequence of this loop! jmp = mem[NEXT] - while (jmp = callPrim(jmp)) != 0 end + while (jmp = callPrim(jmp)) != 0 + println("Evaluating prim $jmp") + end end # Debugging tools