aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2025-01-27 21:44:35 -0500
committerClyne Sullivan <clyne@bitgloo.com>2025-01-27 21:44:35 -0500
commit784f819f976042fbf683a452aa1e46dcff4a49a5 (patch)
treef2e7178599031c377da16c0ff4e4124e20e8c85d
parentd76d97f608ee9b4d61b4cc890ff589580ae4a017 (diff)
return stack words
-rw-r--r--README.md2
-rw-r--r--foci.c8
2 files changed, 8 insertions, 2 deletions
diff --git a/README.md b/README.md
index ca0d89e..721d29f 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@ Register usage is the only platform-specific requirement; otherwise, `foci` is w
dup drop swap rot -rot over tuck @ ! c@ c! + +! - * / mod and or xor = < [ ] ,
cell cell+ cells base here allot latest negate invert 1- 1+ aligned align : ;
literal if then else ' ['] execute decimal hex . emit begin until again while
-repeat
+repeat >r r> 2>r 2r>
```
## Build instructions
diff --git a/foci.c b/foci.c
index e896015..77b4b67 100644
--- a/foci.c
+++ b/foci.c
@@ -158,7 +158,13 @@ I(until, "until", &w_begin) LIT(bz), comma, comma, END
I(again, "again", &w_until) LIT(b), comma, comma, END
I(fwhile, "while", &w_again) FTH(fif), END
I(repeat, "repeat", &w_fwhile) swap, FTH(again), FTH(then), END
-#define LATEST_INIT &w_repeat
+N(pushr, ">r", &w_repeat) { *--rp = (intptr_t **)*sp++; NEXT; }
+N(popr, "r>", &w_pushr) { *--sp = (intptr_t)*rp++; NEXT; }
+N(pushr2, "2>r", &w_popr) { *--rp = (intptr_t **)sp[1];
+ *--rp = (intptr_t **)sp[0]; sp += 2; NEXT; }
+N(popr2, "2r>", &w_pushr2) { *--sp = (intptr_t)rp[1];
+ *--sp = (intptr_t)rp[0]; rp += 2; NEXT; }
+#define LATEST_INIT &w_popr2
void enter_forth(const void * const ptr)
{