commit 04eab09660c6b7418822a8d9573194a6c870f6c7
parent 3bf22fdee12a045a12f624b2518cefa593a2e897
Author: Henry Wilson <m3henry@googlemail.com>
Date: Sun, 30 Jul 2017 15:51:22 +0100
HERE
Diffstat:
3 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/macros.i b/macros.i
@@ -15,9 +15,13 @@
.quad \val
.endm
-.macro variable
+.macro variable init
do dovar
+.ifnb \init
+ .quad \init
+.else
.quad 0
+.endif
.endm
.macro get var
diff --git a/main.s b/main.s
@@ -46,6 +46,7 @@ enter:
.quad 0
COLD: forthword
_cold: do RESETDATA
+ set HEREVAR dictionaryhead
escape 0
escape 96
saycr "aFORTH alpha"
@@ -209,7 +210,7 @@ verb forth WORD
endword
verb forth DICTIONARY
- const dictionaryhead
+ do HERE
2: do DUP
do fetch
const 0
@@ -225,8 +226,16 @@ verb forth DICTIONARY
1: do DROP
endword
+verb forth HEREVAR
+ variable
+ endword
+
+verb forth HERE
+ get HEREVAR
+ endword
+
verb forth FIND
- const dictionaryhead
+ do HERE
2: do dup2
const 8
do plus
diff --git a/makefile b/makefile
@@ -1,6 +1,6 @@
all: bin/aFORTH
@echo Testing...
- @/bin/echo -ne "12 DUP * . CR 10 4 FLAG" | bin/aFORTH
+ @/bin/echo -ne "12 DUP * . CR 10 4 FLAG ] GREET [ GREET" | bin/aFORTH
interactive: bin/aFORTH
@bin/aFORTH