From: Tim Vaughan Date: Sun, 17 Apr 2016 13:01:49 +0000 (+1200) Subject: Debugging first non-primitive word. X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;h=d9652f786f96bb109ea03582db138816db0f8fda;p=forth.jl.git Debugging first non-primitive word. --- diff --git a/src/forth.jl b/src/forth.jl index e8478a4..9da680c 100644 --- a/src/forth.jl +++ b/src/forth.jl @@ -158,6 +158,7 @@ end function defWord(name::AbstractString, wordAddrs::Array{Int64,1}; flags::Int64=0) createHeader(name, flags) + addr = mem[HERE] mem[mem[HERE]] = DOCOL mem[HERE] += 1 @@ -165,6 +166,8 @@ function defWord(name::AbstractString, wordAddrs::Array{Int64,1}; flags::Int64=0 mem[mem[HERE]] = wordAddr mem[HERE] += 1 end + + return addr end # Threading Primitives @@ -543,13 +546,13 @@ TOCFA = defPrim(">CFA", () -> begin return NEXT end) -TODFA = defWord(">DFA", [TOCFA, INCR1, EXIT]) +TODFA = defWord(">DFA", [TOCFA, INCR, EXIT]) #### VM loop #### -#function runVM(reg::Reg) -# jmp = NEXT -# while (jmp = callPrim(reg, jmp)) != 0 end -#end +function runVM() + jmp = NEXT + while (jmp = callPrim(jmp)) != 0 end +end # Debugging tools