aboutsummaryrefslogtreecommitdiff
path: root/forth/forth/jt.fs
diff options
context:
space:
mode:
Diffstat (limited to 'forth/forth/jt.fs')
-rw-r--r--forth/forth/jt.fs42
1 files changed, 42 insertions, 0 deletions
diff --git a/forth/forth/jt.fs b/forth/forth/jt.fs
new file mode 100644
index 0000000..496a439
--- /dev/null
+++ b/forth/forth/jt.fs
@@ -0,0 +1,42 @@
+\ *********************************************************************
+\ *
+\ Filename: jt.txt *
+\ Date: 06.01.2014 *
+\ FF Version: 5.0 *
+\ Copyright: Mikael Nordman *
+\ Author: Mikael Nordman *
+\ *********************************************************************
+\ FlashForth is licensed acording to the GNU General Public License*
+\ *********************************************************************
+\ create an execution table with n entries
+\ each entry consists of 'nn' cell sized comparison value
+\ and 'an' the address of the corresponding word to be executed.
+\ At least two entries must be provided, the last one beeing the
+\ default action.
+-jt
+marker -jt
+
+: jte nip cell+ @ex ;
+: jt ( an nn n -- ) \ compile an execution table
+ ( m -- ) \ execute aword corresponding to m
+ create
+ dup 1- , \ store the table size
+ for
+ , , \ store an entry
+ next
+ does> \ m addr
+ dup @ \ m a n
+ for
+ cell+
+ 2dup @ = \ m a flag
+ if
+ \ a match was found
+ jte rdrop exit
+ then
+ cell+ \ m a
+ next
+ \ Execute the default action.
+ cell+ jte
+;
+ram
+