Refactor: Create INTERPRET word
authorJonas Hvid <mail@johv.dk>
Tue, 3 Dec 2019 18:28:17 +0000 (19:28 +0100)
committerJonas Hvid <mail@johv.dk>
Tue, 3 Dec 2019 18:28:17 +0000 (19:28 +0100)
(We will probably want to write this in assembly when we add more
functionality.)

main.asm

index 21a911cf164675d6dba7fc201559d3c77fdb43a3..8d9c51b77573f2da465b50914b6574acb1f29679 100644 (file)
--- a/main.asm
+++ b/main.asm
@@ -242,6 +242,15 @@ forth HELLO, 'HELLO'
   dq NEWLINE
   dq EXIT
 
+;; The INTERPRET word reads and interprets user input. It's behavior depends on
+;; the current STATE. It provides special handling for integers. (TODO)
+forth INTERPRET, 'INTERPRET'
+  dq READ_WORD
+  dq FIND
+  dq TCFA
+  dq EXEC
+  dq EXIT
+
 ;; .U prints the value on the stack as an unsigned integer in hexadecimal.
 forth_asm DOTU, '.U'
   mov [.length], 0
@@ -305,8 +314,8 @@ forth_asm DOTU, '.U'
 
 forth MAIN, 'MAIN'
   dq HELLO
-  dq READ_WORD, FIND, TCFA, EXEC
-  dq BRANCH, -8 * 5
+  dq INTERPRET
+  dq BRANCH, -8 * 2
   dq TERMINATE
 
 segment readable writable