commit e71693d96a90fdd0850f1b5459ac95dfb19a43b5
parent 2a1dca7c4f70d795ea2e9f403eec3075ab30538c
Author: Christian Ermann <christianermann@gmail.com>
Date: Sun, 3 Nov 2024 14:22:54 -0800
Add 'variable' and 'constant'
Diffstat:
| M | forth.s | | | 27 | +++++++++++++++++++++++++-- |
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/forth.s b/forth.s
@@ -116,7 +116,18 @@ meta_\label:
docol:
push_ret ip
addi ip, w, cell
- NEXT
+ next
+
+dovar:
+ addi w, w, cell
+ push w
+ next
+
+docon:
+ addi w, w, cell
+ load_cell w, 0(w)
+ push w
+ next
.equ name_null, 0
@@ -722,6 +733,18 @@ defword "immediate", 9, 0, 0xF232267A, immediate, postpone
.int swap, store
.int exit
+defword "variable", 8, 0, 0x19385305, variable, immediate
+ .int parse_word, create # create header
+ .int lit, dovar, comma # append 'dovar'
+ .int lit, 0, comma # initialize to zero
+ .int exit
+
+defword "constant", 8, 0, 0x0691EA25, constant, variable
+ .int parse_word, create # create header
+ .int lit, docon, comma # append 'docon'
+ .int comma # initialize to value on stack
+ .int exit
+
.section ".text"
file_get_char:
la w, _bootstrap
@@ -767,7 +790,7 @@ _okay:
word_buffer: .space 255
.balign cell
-_latest: .int name_immediate
+_latest: .int name_constant
_here: .int __here_start
_meta: .int __meta_start