Hi, If you want to do a variable jump vector table, that is fine

If you jump vector table has a known size, you' may also use forth200x 
structures for field names.
That is the approach of forths like VFX Forth for its I/O vectors (GENIO 
drivers)


For something more sophisticated as Finite State Machines you may want to have 
a look at
http://galileo.phys.virginia.edu/classes/551.jvn.fall01/fsm2.htm


Paper explaining it at
http://galileo.phys.virginia.edu/classes/551.jvn.fall01/fsm.html


Greetings
Rafael



________________________________
 De: Enoch <i...@hotmail.com>
Para: amforth-devel@lists.sourceforge.net 
Enviado: Sábado 16 de febrero de 2013 18:47
Asunto: [Amforth] Code snippet
 
Hi,

Excuse me folks, while I am a (very) experienced embedded programmer
Forth for me is a new experience. So here's another joy discovery. The
old Forth sage tell us to use decision tables rather than case and
nested if-s, so here's my "sling" for your review that I use in the
implementation of a state machine:

\ sling table generator, doc via example:

\ : first ." first" ;
\ : second ." second" ;
\ : third ." third" ;
\ ' third ' second ' first sling shot
\
\ 1 shot → second ok
\ -1 shot → ok

: sling create  ( i × xt -- )
    depth , begin depth while , repeat
  does>  ( n -- ? )
    over over @i U<
    if 1+ + @i execute
    else 2drop
    then
;

Cheers, Enoch.


------------------------------------------------------------------------------
The Go Parallel Website, sponsored by Intel - in partnership with Geeknet, 
is your hub for all things parallel software development, from weekly thought 
leadership blogs to news, videos, case studies, tutorials, tech docs, 
whitepapers, evaluation guides, and opinion stories. Check out the most 
recent posts - join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Amforth-devel mailing list for http://amforth.sf.net/
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel
------------------------------------------------------------------------------
The Go Parallel Website, sponsored by Intel - in partnership with Geeknet, 
is your hub for all things parallel software development, from weekly thought 
leadership blogs to news, videos, case studies, tutorials, tech docs, 
whitepapers, evaluation guides, and opinion stories. Check out the most 
recent posts - join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Amforth-devel mailing list for http://amforth.sf.net/
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel

Reply via email to