The OS 9 boot loader uses the r-stack outside of a word in interpret mode. Provide an r-stack implementation which allows r-stack accesses in interpret mode using a separate pseudo stack.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- forth/lib/build.xml | 1 + forth/lib/rstack.fs | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 forth/lib/rstack.fs
diff --git a/forth/lib/build.xml b/forth/lib/build.xml index 34eee40..f1c9a45 100644 --- a/forth/lib/build.xml +++ b/forth/lib/build.xml @@ -8,6 +8,7 @@ -->
<dictionary name="openbios" target="forth"> + <object source="rstack.fs"/> <object source="vocabulary.fs"/> <object source="string.fs"/> <object source="preprocessor.fs"/> diff --git a/forth/lib/rstack.fs b/forth/lib/rstack.fs new file mode 100644 index 0000000..c095a9e --- /dev/null +++ b/forth/lib/rstack.fs @@ -0,0 +1,21 @@ +\ tag: pseudo r-stack implementation for openbios +\ +\ Copyright (C) 2016 Mark Cave-Ayland +\ +\ See the file "COPYING" for further information about +\ the copyright and warranty status of this work. +\ + +\ +\ Pseudo r-stack implementation for interpret mode +\ + +create prstack h# 20 cells allot +variable #prstack 0 #prstack ! + +: prstack-push prstack #prstack @ cells + ! 1 #prstack +! ; +: prstack-pop -1 #prstack +! prstack #prstack @ cells + @ ; + +: >r state @ if ['] >r , exit then r> swap prstack-push >r ; immediate +: r> state @ if ['] r> , exit then r> prstack-pop swap >r ; immediate +: r@ state @ if ['] r@ , exit then r> prstack-pop dup prstack-push swap >r ; immediate