Make S" work inside compiled words
[rrq/jonasforth.git] / main.asm
index 537d0e8e6fe3e3728bc06704d8925001e27f739e..43eef7a7e52ab27a253ad343ec775ae83e0a8b22 100644 (file)
--- a/main.asm
+++ b/main.asm
@@ -160,6 +160,17 @@ forth_asm LIT, 'LIT'
   push rax
   next
 
+;; When LITSTRING is encountered while executing a word, it instead reads a
+;; string from the definition of that word, and places that string on the stack
+;; as (buffer, length).
+forth_asm LITSTRING, 'LITSTRING'
+  lodsb
+  push rsi ; Buffer
+  movzx rax, al
+  push rax ; Length
+  add rsi, rax ; Skip over string before resuming execution
+  next
+
 ;; Given a string (a pointer following by a size), return the location of the
 ;; dictionary entry for that word. If no such word exists, return 0.
 forth_asm FIND, 'FIND'