Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Languages Misc > I found a FORTH...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 1092 of 1154
Post > Topic >>

I found a FORTH stack optimzer, but could use a better version.

by "Rod Pemberton" <do_not_have@[EMAIL PROTECTED] > Jan 6, 2008 at 12:26 AM

I ran across an interesting optimizer for FORTH stack words in java by Ram
Janovski, and Vassilii Khachaturov, dated 2004, here:

  http://black.cs.bgu.ac.il/forth-opt

Depending on which FORTH stack words you select, it'll attempt to generate
a
optimized definition using the input set of words.

  i.e., if you input ab -- ba, for SWAP, and select DROP,DUP,TUCK it'll
output:

    Transforming ab ==> ba
    TUCK ( ab -- bab )
    DROP ( bab -- ba )

  i.e., if you input ab -- ba, for SWAP, and select DROP,DUP,ROT it'll
output:

    Transforming ab ==> ba
    DUP ( ab -- abb )
    ROT ( abb -- bba )
    ROT ( bba -- bab )
    DROP ( bab -- ba )

Anyone aware of other FORTH stack optimizers?  This one seemed pretty
good,
but has some limitations.

   e.g., single FORTH and 2 FORTH words aren't symmetric - missing 2NIP,
2TUCK, -2ROT
   e.g., has PICK but not the opposite, i.e., a "PLACE" - for x86 assembly
conversion
   e.g., doesn't have Koopman's OVER_+, PICK_2, TUCK_2, UNDER, UNDER_+,
etc.
from here:
  http://www.ece.cmu.edu/~koopman/stack_compiler/stack_co.html

   e.g., doesn't generate sequences with "0 PICK", "1 PICK", "0 ROLL", "1
ROLL"
       i.e., won't generate ab -- ba, for SWAP as 1 ROLL, but as:

    Transforming ab ==> ba
    DUP ( ab -- abb )
    DUP ( abb -- abbb )
    3 ROLL ( abbb -- bbba )
    3 ROLL ( bbba -- bbab )
    3 ROLL ( bbab -- babb )
    DROP ( babb -- bab )
    DROP ( bab -- ba )

Anyone know of an improved version, or some other one that's a bit more
advanced?  The sourcecode is available, but it's in java...


Rod Pemberton




 2 Posts in Topic:
I found a FORTH stack optimzer, but could use a better version.
"Rod Pemberton"  2008-01-06 00:26:01 
Re: I found a FORTH stack optimzer, but could use a better versi
anton@[EMAIL PROTECTED]   2008-01-06 18:22:00 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue May 13 18:46:36 CDT 2008.