Shop OBEX P1 Docs P2 Docs Learn Events
PropForth 2.7 — Parallax Forums

PropForth 2.7

prof_brainoprof_braino Posts: 4,313
edited 2010-07-10 19:44 in Propeller 1
Version 2.7 is no long the current release of PropForth
Please see the new thread for PropForth 3.2
http://forums.parallax.com/forums/default.aspx?f=25&m=468264

There is a new version of PropForth on google code http://code.google.com/p/propforth/

PropForth 2.7 has several changes:
fixed the error in the "saveforth" word
updates to documentation
instructions to generate new propforth.spin code

Additional updates to the documentation will be posted in the next week or so,
currently enough is present to get up and running.
Questions and comments are welcome.
Please point out anything that needs clarification.

Notice: PropForth is separate from propellerforth, which unfortunately has not been updated since 2008
and does not have any source available.
PropForth has the spin source posted and can be modified in the source in addition to or in combination with modifying the forth dictionary

Cheers!

braino

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
There are 10 types of people in the world: those who understand binary, and those who don't

Post Edited (prof_braino) : 7/18/2010 2:11:02 PM GMT
«1

Comments

  • mwalimumwalimu Posts: 44
    edited 2010-05-31 16:28
    Very nice.

    I have a project that the interactivity of FORTH would be helpful, but I need another serial port, one port to monitor the prop, one to communicate with other hardware. Is that possible?
  • prof_brainoprof_braino Posts: 4,313
    edited 2010-06-01 16:10
    With forth, everything is permitted. The serial driver built into propforth defaults to using cog7 for the default serial channel on pins 30 and 31. The extension serial driver (serial.f) can be loaded and configured to do whatever you want. The author's notes say that the default cog7 running serial communication has lots of power to spare. If you still need more, there is an assembler timeslicer (aslicer.f) that runs BETWEEN FORTH WORDS, while the standard forth round robin multitasker runs runs between task I/O calls. If the round robin multitasker isn't fast enough (although it probably is), the assembler multitasker ought to do it. There's serial monitor (serialmonitor.f) that goes with the other two, but I haven't gotten that far yet. Of course, I don't know what kind of data rate you are requiring of the serial port(s); and I have not done the Maximum Insane Data Rate Throughput Test (MIDRTPT(c)) yet, but if it can be done at all, there is a good chance that it can be done in forth at nearly assembler speed, and in a shorter time than using only assembler. (and any bottle necks can be optimized in assembler, but that's outside my area). If what you want can be done in SPIN, then of course it would be quickest to pull an object from the OBEX.

    If you get a change to look at the documentation on the serial.f extension, please post comments and questions. The documentation is being re-written so that an average person other than the author (i.e. me) can understand it, and your questions will move a given topic towards the top of the list.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    There are 10 types of people in the world,
    This who understand binary, and those who don't
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-06-01 17:26
    braino,

    Just out of curiosity, why is the serial driver statically assigned to a specific cog? Typically, you do not want to make static cog assignments but, rather, let cognew do the assigning for you. cogstart coginit should almost never be used for starting cogs.

    -Phil

    Post Edited (Phil Pilgrim (PhiPi)) : 6/1/2010 8:37:59 PM GMT
  • prof_brainoprof_braino Posts: 4,313
    edited 2010-06-01 20:10
    @Phil

    That's a question for Sal Sanci. As far as I know from the comments, Spin starts in cog0, starts the serial driver in cog7, and starts cog6 as a forth cog. The other cogs are idle until you do something in cog 6 to start them as additional (forth) cogs.

    I think its might be because this forth is closer to assembler than spin. Forth tends to be "close to the metal". Neither of the words cognew or cogstart appear in the in the source code. This makes sense since those are spin words, and this forth is based on the small section of assembler that precedes "ForthDictStart" in the propforth.spin file. The spin portion only uses coginit and cogstart, if my search tool is working.

    All those words to do with controlling cogs from within propforth are implemented in propforth, near as I can tell.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    There are 10 types of people in the world,
    This who understand binary, and those who don't
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-06-01 20:32
    'Sorry, I meant coginit, not cogstart. Being "close to the metal" is no reason to use it instead of cognew. A well-written program should be cog-agnostic, except for storing the cog numbers returned by cognew so that those cogs can be stopped later.

    If everybody used coginit, chaos and conflict would reign. cognew prevents that.

    -Phil

    Post Edited (Phil Pilgrim (PhiPi)) : 6/1/2010 8:38:19 PM GMT
  • prof_brainoprof_braino Posts: 4,313
    edited 2010-06-01 22:50
    Like I said, that's a question for the author. It looks like coginit was chosen so that a specific cog could be selected. The cogs can be stopped and started using the words provided.

    I'm a little hazy to how chaos and confusion reigns as a result of coginit. Do you mean a well written SPIN program should be cog-agnostic?
    If this is in the context of running forth as an object under spin, or running spin object under forth, I don't think that is supported in this version.
    So far, I've only seen it as "forth only" once propforth is running.

    I remember a discussion about an 8 bit token threaded forth built on the spin ROM intended to run under spin and/or call spin object from forth. That would be a later version or even a separate project. Please see update 5 or so posts below

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    There are 10 types of people in the world,
    Those who understand binary, and those who don't

    Post Edited (prof_braino) : 6/6/2010 8:36:00 PM GMT
  • caskazcaskaz Posts: 957
    edited 2010-06-03 12:59
    Hi.

    I'm going to install PropForth, but I'm confused.

    On "Getting Started",
    Download PropForth.spin
    Load into eeprom
    Start up TeraTerm

    On "VerifyPropforth ",
    Upload spinmakerPart1.f to the prop
    Upload spinmakerPart2.f to the prop
    spinmaker 'rebuilding the entire forth dictionary
    copy the output from ForthDictStart to ForthMemoryEnd of spinmaker
    output of spinmaker into PropForth-template.spin.



    But on "RebuildingPropForth"
    Upload PropForthPart1.f and PropForthPart2.f to prop.
    load spinmaker
    spinmaker


    no upload PropForthPart1.f and PropForthPart2.f on "Getting Started",
    upload spinmakerPart1.f and spinmakerPart2.f on "VerifyPropforth".

    Which is correct way to install?
  • prof_brainoprof_braino Posts: 4,313
    edited 2010-06-04 19:25
    Use VerifyPropForth

    On the page
    http://code.google.com/p/propforth/wiki/PropForth
    links have been reviewed for the pages
    PropForthStatus
    GettingStarted
    VerifyPropforth
    DownloadSourceText
    DownloadPropforthSource

    Those pages should be clear, correct and accurate for the current version (let me know where they are not and I will fix them)

    The remaining links on the page have not been reviewed and may or may not have useful information:

    The following pages are under review:

    * SavingPropForth
    * RebuildingPropForth
    * AddingSerialMonitor

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    There are 10 types of people in the world,
    This who understand binary, and those who don't

    Post Edited (prof_braino) : 6/4/2010 8:17:32 PM GMT
  • prof_brainoprof_braino Posts: 4,313
    edited 2010-06-04 20:12
    [noparse][[/noparse]A bit more explanation]

    The word spinmaker generates the forth definitions that go at the end of the propforth.spin file.

    It makes the forth definitions from the forth image that is currently running on the prop. This is what is happening in the VerifyPropForth page.

    Here's what was different in the old version:
    In the last version of the instructions, the author was trying to demonstrate how one would go about redefining the entire forth image in high level forth (rather than assembler, which the prototypes had been up to that point). This is what was being demonstrated in the RebuildingPropForth page. He just didn't say so. I didn't get it either. that's why we started rewriting the documentation. BUT you can still do it the RebuildingForth way. Anybody that can write a valid forth system can define a forth for the prop IN FORTH, load those definitions into propforth, use spinmaker to make spin code, and generate a eeprom-able image by putting that spin code into the spin code template and loading to the prop using Propeller Tool. We walked through it, and it worked, but figured out that this method is too confusing, so we made the VerifyPropForth page. But both are correct. The thing is, after RebuildingPropForth was done once successfully, there was no longer a need for switch from the assembler to forth, because the starting image is now in forth.

    Propforthpart1.f and propforthpart2.f are the original forth definintions that were compiled by the minimal prototype forth kernel to produce the image that became propforth 2.7. After those definitions were compiled into the dictionary, the word "saveforth" was run to save the image into eeprom. Next, the device was rebooted and the definitions for spinmaker were loaded (compiled into the dictionary). The spinmaker word was executed to product a big chunk of text, which was captured from the terminal program screen, and copy and psted into propforth-template.spin, and this resulting file was saved as propforth.spin.

    Now, if propforth.spin (downloaded from googlecode) is loaded into a propeller, and spinmaker is loaded and executed, it will produce the exact source text as found in the assembler section of propforth.spin between the ForthDictStart and the ForthMemoryEnd text. Also, these definitions are identical to the definitions in PropForthpart1.f and propforthpart2.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    There are 10 types of people in the world,
    Those who understand binary, and those who don't

    Post Edited (prof_braino) : 6/6/2010 8:38:02 PM GMT
  • jazzedjazzed Posts: 11,803
    edited 2010-06-04 20:44
    Phil Pilgrim (PhiPi) said...
    A well-written program should be cog-agnostic ...
    Hmm....

    "Cognostic" - One of a sect of propeller followers who lived near the gushing oil sea in pre-turboprop antiquity in whose writings we find the belief that it is not possible for the creator (of instructions) to produce a perfect system with an affinity to any given cog and such systems tend toward chaos for users more than cogs selected from a pool (just one definition).

    Forgive me .... I hope all Forth users find great happiness with PropForth.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Pages: Propeller JVM
  • prof_brainoprof_braino Posts: 4,313
    edited 2010-06-06 20:31
    Hi all

    Turns out I was mistaken in my previous post, I spoke with the author and have the following corrections:

    There is no technical reason why the cogstart command cannot be used rather than the coginit command. For the purpose of propforth 2.7 the author wanted to control exactly which specific cog was performing each specific function, but this need not always be the case.

    There is no technical reason why spin cannot call forth, and forth run as any other spin object. The author is defining the method to communicate with forth from spin. These will be posted and documented shortly.

    There is no technical reason why forth cannot call spin routines. The author designed propforth to suit his specific need, which could not easily be addressed in spin due to size and timing constraints (or something else). In situations where these constraints are not an issue, it would not cause problems for forth to pass parameters to a spin object, run the spin object and get the results. The author is defining words for this purpose, and they will also be posted and documented shortly.

    Propforth 2.8 (or so) should support calling forth from spin, and calling spin from forth. A new thread will be posted when this happens.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    There are 10 types of people in the world,
    Those who understand binary, and those who don't
  • caskazcaskaz Posts: 957
    edited 2010-06-13 04:06
    Hi.

    I have question.

    Cog6 ok
    16 16 st?
    ST: 00000016 00000016
    Cog6 ok
    + st?
    ST: 0000002C
    32 32 st?
    ST: 0000002C 00000032 00000032
    + st?
    ST: 0000002C 00000064
    + st?
    ST: 00000090
    Cog6 ok
    
    



    16 + 16 = 2C
    32 + 32 = 64

    Display for result is decimal or hex?
    Is this bug?
    Or another reason?

    caskaz
  • kuronekokuroneko Posts: 3,623
    edited 2010-06-13 04:44
    16 + 16 = 2C
    32 + 32 = 64
    


    The first is only true for hex, the latter is true for both decimal and hex. Provided the base isn't changed behind the scenes and/or without user interaction you end up with hex as the common denominator.

    Not sure if it's implemented (it should) but try

    base .
    


    and see what it says.
  • caskazcaskaz Posts: 957
    edited 2010-06-13 05:12
    Hi, Thanks.

    base .
    UNDEFINED WORD base
    Cog6 ok
    
    
  • caskazcaskaz Posts: 957
    edited 2010-06-13 08:07
    decimal
    Cog6 ok
    16 16 st?
    ST: 00000010 00000010
    Cog6 ok
    + st?
    ST: 00000020
    Cog6 ok
    
    hex
    Cog6 ok
    16 16 st?
    ST: 00000016 00000016
    Cog6 ok
    + st?
    ST: 0000002C
    Cog6 ok
    
    



    I check word.
    : hex 10 mcwBase w! ;
    : decimal A mcwBase w! ;
    I seem to be word"decimal" operate like to be "hex".
    Operation of word"hex" is strange.
  • kuronekokuroneko Posts: 3,623
    edited 2010-06-13 11:02
    caskaz said...
    I check word.
    : hex 10 mcwBase w! ;
    : decimal A mcwBase w! ;
    I seem to be word"decimal" operate like to be "hex".
    Operation of word"hex" is strange.
    Looks fine to me. mcwBase holds the current numeric base (10 for decimal, 16 for hex etc). If you switch to decimal then all I/O is treated as decimal. st? uses .long internally which always outputs in hex. So entering 16 16 st? will display 00000010 00000010 which is expected. Maybe you should start using dup . instead of st? (I'm aware that st? prints the whole stack, point is that . honours the current base).

    In the second example you switch to hex so the st? output matches your input more closely. HTH
  • caskazcaskaz Posts: 957
    edited 2010-06-13 12:32
    Thanks, kuroneko.
    Sorry, it's my misunderstanding.
  • prof_brainoprof_braino Posts: 4,313
    edited 2010-06-13 13:23
    The strange looking names for some (most) of the standard words, like "BASE" being:

    mcwBase

    are an artifact of design considerations of the previous propject, spinforth. In that project, the author intended to have each forth running an independent dictionary in each cog. The naming convention selected for that purpose is more or less decribed in the comments at the beginning of

    Propforth.spin

    The experience form the spinforth project indicated that a more efficeint method would be to have a common dictionary, and any special words that need to be optimized or reduced in size be implemented in assembler (which is how this is usually done in forth) and these optimized assembler definitions could then reside only in the cogs where they are needed. This simplifies the overall structure of the new version propforth, and still allows special words in each cog as needed.

    The next version of propforth (3.0 possibly) is to have different names such that it will be closer to a standard forth, where "mcwBase" will be renamed BASE, cog memory access will be @ and ! as these are long only; HUB memory access will be something like C@ C! W@ W! L@ L! for byte, word and long access, and only prop-specific words to support standard words will be in lowercase.

    At this time, this work is not complete. In addition to the items described, there are other issues due to the unique nature of the prop that need to be worked through.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    There are 10 types of people in the world,
    Those who understand binary, and those who don't

    Post Edited (prof_braino) : 6/13/2010 1:57:41 PM GMT
  • prof_brainoprof_braino Posts: 4,313
    edited 2010-06-13 13:39
    The word "st?" displays the current stack in hex, formatted to 8 digits.
    This forth defaults in hex, and the code expects the base to be set to hex at this point.

    One of the planned changes for version 3.0(?) is to implement more standard words like
    .S etc

    If you are interesting in helping with the work on the "standard forth" version of PropForth, please send me a message.
    Your inputs would be appreciated.

    Tasukarimasu Arigato

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    There are 10 types of people in the world,
    Those who understand binary, and those who don't
  • caskazcaskaz Posts: 957
    edited 2010-06-15 06:18
    Hi.
    I checked about mcwBase.
    But same as hex and decimal.
    What's wrong about my idea?


    hex
    Cog6 ok
    mcwBase w@ . cr
    10
    Cog6 ok
    
    decimal
    Cog6 ok
    mcwBase w@ . cr
    10
    Cog6 ok
    
    
  • kuronekokuroneko Posts: 3,623
    edited 2010-06-15 06:30
    caskaz said...
    I checked about mcwBase.
    But same as hex and decimal.
    What's wrong about my idea?
    Nothing wrong with it, well, depends on what you expect. The fact is that the numeric base printed in said base is always 10, i.e. 16 (hex) printed in hex is ($)10, 10 (decimal) printed in decimal is 10, 2 (binary) printed in binary is (%)10 etc. Try this word (untested):

    : current_base mcwBase dup w@ dup decimal . swap w! ;
    

    Post Edited (kuroneko) : 6/15/2010 6:37:01 AM GMT
  • caskazcaskaz Posts: 957
    edited 2010-06-15 06:55
    Kuroneko-san, Thanks.
    I see reading your explanation.
    Your word works.

    I checked below;
    hex
    Cog6 ok
    mcwBase w@ st? cr
    ST: 00000010
    
    Cog6 ok
    decimal
    Cog6 ok
    mcwBase w@ st? cr
    ST: 00000010 0000000A
    
    Cog6 ok
    
    
  • caskazcaskaz Posts: 957
    edited 2010-06-15 11:42
    Hi.
    I try to blink LED.
    But LED not blink.
    After word "blink", Forth cogs 4 - 6. 1 cog used?

    And I made blink.f to adding "FL". But loaded it, message was "UNDEFINED WORD".
    What's wrong?

    Forth cogs: 5 - 6
    PropForth v2.7 2010MAY26 14:50 1
    Cog6 ok
    
    wvariable T
    Cog6 ok
    wvariable dT
    Cog6 ok
    wvariable value
    Cog6 ok
    : blink decimal 1 value ! 40000000 dT ! 1 dira ! value outa ! cnt T !
    7 0 do
      value invert outa !
      waitcnt T @ dT @
    loop ;
    Cog6 ok
    blink
    Forth cogs: 4 - 6
    PropForth v2.7 2010MAY26 14:50 1
    Cog6 ok
    
    



    caskaz

    Post Edited (caskaz) : 6/15/2010 11:47:17 AM GMT
  • kuronekokuroneko Posts: 3,623
    edited 2010-06-15 14:44
    Your main problem are addresses and/or their values. Try this (demoboard pin 16):

    : blink hex 10000 dup outa ! dira !
      cnt @ 0 m@ +
      7 0 do
      0 m@ waitcnt
      outa dup @ invert swap !
      loop drop ;
    
  • prof_brainoprof_braino Posts: 4,313
    edited 2010-06-15 15:31
    caskaz said...
    Hi.
    I checked about mcwBase.
    But same as hex and decimal.
    What's wrong about my idea?


    hex
    Cog6 ok
    mcwBase w@ . cr
    10
    Cog6 ok
    
    decimal
    Cog6 ok
    mcwBase w@ . cr
    10
    Cog6 ok
    
    



    Something like this might go in "developer extensions" if you have such a thing

    "Period" character in the front of a word means "print ..."
    : .BASE mcwBase w@ hex  ." Base is "          \ get current base, switch to hex
                       dup 10 = if ."  Hex "      else 
                       dup  A = if ."  Decimal "  else 
                       dup  2 = if ."  Binary "   else
                                   ."  unusual "  then then then
                       mcwBase w! ;               \ restore original base
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    There are 10 types of people in the world,
    Those who understand binary, and those who don't
  • caskazcaskaz Posts: 957
    edited 2010-06-17 23:40
    Thanks kuroneko-san, prof_braino.
  • caskazcaskaz Posts: 957
    edited 2010-06-19 06:56
    Hi.
    I try to make lcd-driver.
    Although success to send cammnad for lcd, parameter not yet.

    I tested below: (trying to write data[noparse][[/noparse]$77] to v-ram[noparse][[/noparse]42768bytes])
    lcd_initial
    Cog6 ok
    : test 5C command A710 0 do 77 dup parameter loop ;
    Cog6 ok
    test
    Forth cogs: 4 - 6
    PropForth v2.7 2010 May26 14:50 1
    Cog6 ok
    
    



    Why PropForth is reset?
    And using cog increase from cog:5-6 to cog:4-6.

    LCD is displyes initial v-ram's status(red/blue/green's dot).
    I think command-sending is success because command(display on/off, display invert/normal) is good.
    
    FL
    
    : command 
      2 mpxl 4 mpxl                \ A0 = L  WRX = L
      3 lshift outa @ or outa !            \ outa <-- data
      4 mpxh 2 mpxh                \ WRX = H A0 = H 
      FFFFF807 outa @ and outa !        \ D0 - D7(P3 - P10) clear
    ;
    
    : parameter
      4 mpxl                    \ WRX = L
      3 lshift outa @ or outa !            \ outa <-- data
      4 mpxh                \ WRX = H     
      FFFFF807 outa @ and outa !        \ D0 - D7(P3 - P10) clear
    ;
    
    : lcd_initial 0 b 0 do dup pxo 1+ loop drop    \ P0 - P10 output set
      1 dup mpxh mpxl            \ RESX P0 = H to L
      2 mpxh                \ A0 P1 = H
      4 mpxh                \ WRX P2 = H
      1 del_ms
      1 mpxh                \ RESX P0 = L
      1 del_ms
      94 command                \ Sleep Disable
      AF command                \ Display On
    ;
    
    



    caskaz

    Post Edited (caskaz) : 6/19/2010 7:04:12 AM GMT
  • kuronekokuroneko Posts: 3,623
    edited 2010-06-19 07:11
    : test 5C command A710 0 do 77 dup parameter loop ;
    


    As far as I can tell parameter consumes a single parameter from the stack. Given that you duplicate the 77 inside the loop you're probably running out of stack. Just get rid of the dup.
  • prof_brainoprof_braino Posts: 4,313
    edited 2010-06-19 13:43
    caskaz said...
    Hi.
    test
    Forth cogs: 4 - 6
    PropForth v2.7 2010 May26 14:50 1
    Cog6 ok
    
    



    Why PropForth is reset?
    And using cog increase from cog:5-6 to cog:4-6.


    [noparse][[/noparse]/code]

    caskaz

    When a word executes and causes a stack underflow or overflow, and affects more than the first stack item, the cog is reset.
    reset also actives the next cog as a forth cog. There are other conditions that cause resets, but not all are documented.

    This looks like one of your words has an error.

    The messages indicate the severity or result of the error. However, the MEANING of the messages is not yet documented.
    But here's what I think it means:
    The entire propeller might not have reset. Resting the entire propeller would not have displayed cogs 4-6, it would have displayed 5-6
    So just the cog reset, but word that had an issue had some bad effect beyond that one cog, and recovery involved a bit more than resetting the single cog.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    There are 10 types of people in the world,
    Those who understand binary, and those who don't
  • caskazcaskaz Posts: 957
    edited 2010-06-20 02:54
    Hi.
    Thanks kuroneko-san.
    : test 5C command 77 A710 0 do dup parameter loop drop ;
    
    



    Thanks prof_braino.
    In case of executing wrong code, finally massage is " Forth cogs: 0 - 6".
    Actually proceeding cogs: 0 - 6?

    cog?
    Forth cogs: 0 - 6
    Cog6 ok
    
    




    ffcog w@ wvariable ffcog ffcog w!
    
    


    Definition of ffcog is different. no : and ;.
    I cannot understand word-ffcog.
    ffcog call onself by ffcog?

    Post Edited (caskaz) : 6/20/2010 5:20:45 AM GMT
Sign In or Register to comment.