From: Jonas Hvid Date: Fri, 6 Dec 2019 12:30:54 +0000 (+0100) Subject: Add variables 'LATEST' and 'HERE' X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=623eb650651ba4105e4e91239c52b04ed0e5cd85;p=rrq%2Fjonasforth.git Add variables 'LATEST' and 'HERE' These will be used for compilation. --- diff --git a/main.asm b/main.asm index 183be74..cbf8a13 100644 --- a/main.asm +++ b/main.asm @@ -372,6 +372,19 @@ forth STATE, 'STATE' dq LIT, var_STATE dq EXIT +;; Get the location of the LATEST variable. It can be set with '!' and read with +;; '@'. +forth LATEST, 'LATEST' + dq LIT, latest_entry + dq EXIT + +;; Get the location at which compiled words are expected to be added. This +;; pointer is usually modified automatically when calling ',', but we can also +;; read it manually with 'HERE'. +forth HERE, 'HERE' + dq LIT, here + dq EXIT + forth MAIN, 'MAIN' dq HELLO dq INTERPRET @@ -380,6 +393,9 @@ forth MAIN, 'MAIN' segment readable writable +;; The LATEST variable holds a pointer to the word that was last added to the +;; dictionary. This pointer is updated as new words are added, and its value is +;; used by FIND to look up words. latest_entry dq initial_latest_entry ;; The STATE variable is 0 when the interpreter is executing, and non-zero when @@ -397,6 +413,10 @@ DOTU.rbuffer rq 16 DOTU.length dq ? DOTU.printed_length dq ? +;; Reserve space for compiled words, accessed through HERE. +here dq here_top +here_top rq $2000 + ;; Return stack rq $2000 return_stack_top: