From: Tim Vaughan Date: Mon, 11 Apr 2016 12:03:51 +0000 (+1200) Subject: I/O X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;h=a9699beabb872b9859bf130d017f35caba72789c;p=forth.jl.git I/O --- diff --git a/src/forth.jl b/src/forth.jl index aac4c2a..5838aea 100644 --- a/src/forth.jl +++ b/src/forth.jl @@ -14,16 +14,23 @@ jmp = 0 primitives = Array{Expr,1}() memory = Array{Int64,1}(64*1024) -LATEST = 0 -HERE = 1 +latest = 0 +here = 1 # Intperpreter state -STATE = 0 +state = 0 # Current radix -BASE = 10 +base = 10 + +# Input buffer + +tib_size = 4096 +tib = length(memory) - tib_size +numtib = 0 +toin = 0 # Stack manipulation functions @@ -158,10 +165,10 @@ end) # Built-in variables -defVar("STATE", :STATE) -defVar("HERE", :HERE) -defVar("LATEST", :LATEST) -defVAR("BASE", :BASE) +defVar("STATE", :state) +defVar("HERE", :here) +defVar("LATEST", :latest) +defVar("BASE", :base) # Constants @@ -208,7 +215,14 @@ end) # I/O +defConst("TIB", tib) +defVar("#TIB", :numtib) +defVar(">IN", :toin) + KEY = defPrim("KEY", quote + if toin >= numtib + + end jmp = NEXT end)