From 2f83a0bea9da444e3d70569eba3d6847ca02be03 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Fri, 21 Sep 2018 21:59:17 +0200 Subject: ... --- forth/forth/jt.fs | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 forth/forth/jt.fs (limited to 'forth/forth/jt.fs') 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 + -- cgit v1.2.3