aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md7
-rw-r--r--foci.c15
2 files changed, 15 insertions, 7 deletions
diff --git a/README.md b/README.md
index b6634f6..ca0d89e 100644
--- a/README.md
+++ b/README.md
@@ -9,9 +9,10 @@ Register usage is the only platform-specific requirement; otherwise, `foci` is w
## Available words
```
-dup drop swap rot -rot over tuck @ ! c@ c! + +! - * / mod and or xor _c [ ]
-, cell cell+ cells _d base here allot latest negate invert 1- 1+ aligned align
-: ; literal _b _bz if then else \' [\'] execute decimal hex . emit
+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
```
## Build instructions
diff --git a/foci.c b/foci.c
index 8dedfbd..e896015 100644
--- a/foci.c
+++ b/foci.c
@@ -26,8 +26,8 @@ static intptr_t dict[100] = {
#define state dict[0]
#define BASE dict[1]
#define LATEST dict[2]
-#define begin dict[3]
-static intptr_t *here = &begin;
+#define BEGIN dict[3]
+static intptr_t *here = &BEGIN;
static char *in;
static intptr_t * saved_sp;
@@ -115,7 +115,9 @@ N(mod, "mod", &w_ndiv) { sp[1] %= sp[0]; ++sp; NEXT; }
N(and, "and", &w_mod) { sp[1] &= sp[0]; ++sp; NEXT; }
N(or, "or", &w_and) { sp[1] |= sp[0]; ++sp; NEXT; }
N(xor, "xor", &w_or) { sp[1] ^= sp[0]; ++sp; NEXT; }
-N(compname, "_c", &w_xor) ;
+N(eq, "=", &w_xor) { sp[1] = sp[0] == sp[1]; ++sp; NEXT; }
+N(lt, "<", &w_eq) { sp[1] = sp[0] > sp[1]; ++sp; NEXT; }
+N(compname, "_c", &w_lt) ;
C(intr, "[", &w_compname) { state = 0; NEXT; }
N(comp, "]", &w_intr) { state = -1; NEXT; }
N(comma, ",", &w_comp) { *here++ = *sp++; NEXT; }
@@ -151,7 +153,12 @@ W(decimal, "decimal", &w_execute) LIT(10), LIT(&BASE), poke, END
W(hex, "hex", &w_decimal) LIT(16), LIT(&BASE), poke, END
N(dot, ".", &w_hex) ;
N(emit, "emit", &w_dot) { foci_putchar(*sp++); NEXT; }
-#define LATEST_INIT &w_emit
+I(begin, "begin", &w_emit) FTH(here), LIT(sizeof(intptr_t)), sub, END
+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
void enter_forth(const void * const ptr)
{