Menu

Evaluate tool

2024-07-30
2024-08-01
  • Pere font vilanova

    in other forth versions we can do:
    test r| s" : test1 1 2 + . ; : test2 3 5 * . ; " evaluate | evaluate ;
    this word compile the words test1 and test2 ( or more if you like)
    is there any tool in flash forth to simulate these words?.... or this capacity?
    also s" can be used in interpret or in compile mode.
    thank you for your information
     
  • Pere font vilanova

    sorry must be
    :test ----------

     

    Last edit: Pere font vilanova 2024-07-30
  • Mikael Nordman

    Mikael Nordman - 2024-07-30

    S" somecode" evaluate
    should work.
    S" works in interpret and compile mode since a year back.
    But I did not understand all the other stuff you wrote.

     

    Last edit: Mikael Nordman 2024-07-30
  • Pere font vilanova

    thanks Mikael, but in my scamp3 from Udamonic the word evaluate doesn't exist. Also the word s" is only in interpret mode...
    in esp32forth the words z", r| , r" are used. you can use it to save a full page of words, variables, etc and later compile them.
    if i use the flash forth in arduino uno R4 are the above comments implemented?

     
  • Mikael Nordman

    Mikael Nordman - 2024-07-30

    John is using an older FF as base for his product.
    Here is S" that works in interpret state.
    It was introduced 13.1.2024 to PIC24.

    : S" state if postpone s" else [char] " parse then ; immediate
    S" : 5+ 5 + ;" evaluate
    

    You can compile EVALUATE from source code, but it does not work with a compiled string in flash.
    So you have to copy the string to ram first.
    https://sourceforge.net/p/flashforth/code/ci/master/tree/forth/core.fs

    ram create eval-buf 80 allot
    : test S" : 4+ 4 + ;" ;
    test eval-buf place
    eval-buf c@+ evaluate
    

    Those ESP32forth words do not exist in FlashForth. But I think they could be implemented.

    I have prepared block words and a full screen block editor. I have not published it yet.
    It stores the blocks in flash, so it eats away from your free program memory unless you have a 128 KB or bigger flash in your PIC24 chip.

    FF does not work on Arduino R4, it has an ARM.

     
  • Pere font vilanova

    thank you Mikael for all your information. the words S" and evaluate are working perfectly.
    I tryied your example in my scamp but in works also without copy to ram....
    test evaluate works directly.
    Regarding the block words you are preparing I will wait for them. maybe we can use them for the 2 MB expanded memory of Scamp3. I would like to have a file system storing in this memory.

     
    • Mikael Nordman

      Mikael Nordman - 2024-08-01

      I tried your example in my scamp but in works also without copy to ram....

      Even if it works for you, there are two kinds of word parsing in FF depending on which version you have.
      FF has always written the word length byte into the input buffer, and if the input buffer is a string in flash, the string will be corrupted. And result in extra flash updates.
      But, for a sometime, maybe a few years back, there were FF versions that did not write the length byte to the input buffer. Instead it copies each word to PAD in ram. It seemed a good idea at first, but it resulted in an inoperable FF if the ram dictionary pointer pointed to outside a valid ram address. So that change was reversed this year.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.