aboutsummaryrefslogtreecommitdiff
path: root/forth/forth/jt.fs
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2018-09-29 01:02:00 +0200
committerDimitri Sokolyuk <demon@dim13.org>2018-09-29 01:02:00 +0200
commit79cabd5b1c8bcd9f50dc49e77776e713a57dff48 (patch)
tree6eb73857e9c174610839291cf05a02d77fc82b8c /forth/forth/jt.fs
parent247df3bb9d4c89d4e5ff18dcc23ba1c9532f28c0 (diff)
parent110a6411bae421260476eacf6173897c1d1f4b8a (diff)
Merge branch 'master' of dim13.org:elegoo
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
+