Added CHAR and EXECUTE
authorTim Vaughan <tgvaughan@gmail.com>
Sat, 23 Apr 2016 02:02:37 +0000 (14:02 +1200)
committerTim Vaughan <tgvaughan@gmail.com>
Sat, 23 Apr 2016 02:02:37 +0000 (14:02 +1200)
src/forth.jl

index 69f703e..d6a10e6 100644 (file)
@@ -824,6 +824,22 @@ QUIT = defWord("QUIT",
     INTERPRET,
     BRANCH,-2])
 
+# Odds and Ends
+
+CHAR = defPrim("CHAR", () -> begin
+    callPrim(mem[WORD])
+    wordLen = popPS()
+    wordAddr = popPS()
+    word = getString(wordAddr, wordLen)
+    pushPS(Int64(word[1]))
+
+    return mem[NEXT]
+end)
+
+EXECUTE = defPrim("EXECUTE", () -> begin
+    return mem[popPS()]
+end)
+
 #### VM loop ####
 function runVM()
     jmp = mem[NEXT]