[OpenBIOS] [PATCH 1/3] bootstrap.fs: add pseudo r-stack implementation for interpret mode

Mark Cave-Ayland mark.cave-ayland at ilande.co.uk
Sun Jul 17 16:20:57 CEST 2016


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 at ilande.co.uk>
---
 forth/bootstrap/bootstrap.fs |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/forth/bootstrap/bootstrap.fs b/forth/bootstrap/bootstrap.fs
index 0668cf7..cb791f8 100644
--- a/forth/bootstrap/bootstrap.fs
+++ b/forth/bootstrap/bootstrap.fs
@@ -1587,4 +1587,18 @@ false value capital-hex?
   here 200 allot tmp-comp-buf !
 ;
 
+\
+\ Pseudo r-stack implementation for interpret mode
+\
+
+variable prstack 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
+
 \ the end
-- 
1.7.10.4




More information about the OpenBIOS mailing list