Shop OBEX P1 Docs P2 Docs Learn Events
PropForth - imaginary bug — Parallax Forums

PropForth - imaginary bug

LoopyBytelooseLoopyByteloose Posts: 12,537
edited 2012-10-29 13:55 in General Discussion
I was running a blinking LED program in the PropForth V5.0 html (Example 2) and found that using the infinite loop Begin..... Again results in the Serial console being ignored.

Once entered, the only way to exit is via a hard reset of the Propeller.

I would like the following:
1. Being able to use a CNTL code from the terminal to drop out of the loop and return to stack.
2. Being able to code one cog to enter an infinite loop and then being able to shift to another cog for other tasks.

I am not sure if this is a bug or I just don't know enough.

I guess I can use Saveforth to retain the word before calling it, but if you just immediately try to run the word, there is no means to save your work. And in the case of using Minicom, you have to disconnect the wire before quiting OR the exit from your terminal will reset the Propeller somehow.

Comments

  • mindrobotsmindrobots Posts: 6,506
    edited 2012-10-27 06:07
    I don't think these are bugs, more design decisions.

    (my example keywords may be off the mark a bit - my memory is old and fading and I haven't PropForth'd in a while but the ideas are relatively sound)

    For #1, I don't think you want an infinite loop (or any loop for that matter) incurring keystroke detection overhead unless you explicitly code it. Through the use of the key? word (I think there is one that waits for a key to be pressed and another that just checks if a key was presed, but I forget), you can check for console input and then abort or continue as needed. This way, your looping word can incur overhead if you want it and my looping keyword doesn't.

    For #2, write your looping word and then from the console (COG talking to serial I/O), use the cogx word to start your looping word on another COG. All the COGs share the same dictionary, so it doesn't matter which COG runs which word. You can move the console around and you still see the same dictionary.

    Try "loopy n cogx" where loopy is the word you wrote and want to run on another COG and n is the number of one of your free COGs. Should you want to kill the looping COG, then you can use "n cogstop" to kill it. If I remember, there are both cogstop and cogreset words in PropForth.

    when developing, saveforth is your friend. When you reset to a saved image, you can always forget back to your "good" point in the dictionary and add in the stuff you are testing again after fixing something.
  • Duane C. JohnsonDuane C. Johnson Posts: 955
    edited 2012-10-27 06:23
    Hi Loopy;

    Yes, it would appear to be a bug, but its not.

    Unlike most languages which attempt to "Hold Your Hand" with the result of larger, slower code.
    Forth does virtually no error checking. It leaves this up to you if you want it.

    If you need a "Bail Out" in your WORD you have to put it in their yourself.

    The philosophy of forth is to keep core words as simple and speedy as possible.

    Duane J
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-27 07:58
    Okay, since youall claim this is NOT a bug....
    How do I run 4 infinite loops on 4 separate cogs?. Currently, I only can run one on one cog.

    BTW, philosophy is the luxury of a full belly, I'd prefer functionality leaning towards simplicity.

    Yes, I considered adding key and key?, but it appears the rs232 is shut out completely, maybe key? would revive the connection.

    ANS Forth does have 'bail out' from the terminal for any word that is running. I'll have to look around a bit for it, but there is one. I fear this is more fundamental and about the Propeller lacking interrupts.

    I will try starting it on another cog as advised in #2. I guess I am that idiotic stage where I know just enough to start screaming 'bugs!'
  • mindrobotsmindrobots Posts: 6,506
    edited 2012-10-27 08:28
    Loopy,

    There are lots and lots of words in PropForth that ate non standard and are only found in the HTML doc (before that, you got to dig through the code).

    You have probably already figured this out. When you start PropForth, COG7 is running the serial interface to the PC and all the others are running a PF interpreter. The console I/O is connected to COG6. If you want to change console I/O, there is a word >con which will make any COG the one you at talking to through the terminal. 0 >con makes COG0 the active console COG, for example.

    Assuming you reset and haven't changed anything, the following will start your infinite-loop word on COGs 0-3:

    Infinite-loop 0 cogx
    Infinite-loop 1 cogx
    Infinite-loop 2 cogx
    Infinite-loop 3 cogx

    At this point, COG0-3 are looping in your word, COG4 and COG5 are idle in the PF interpreter and 6 is talking to you through the console and 7 is doing serial I/O with the PC.

    There are cogs top and/or cog reset words (I forget which and have no handy reference) to stop the cogs you started.

    Now, you have complete mastery of a Propeller environment!!

    If you want to build H/W interrupts, you have plenty of pins to play with. Set one in one cog and check it in another!!

    EDIT: I was going to fix the iPad typos but I'm too lazy today. If anything doesn't make sense or can't be deciphered, just ask! :0)
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-27 08:39
    Thank you, I have to do my homework before I say anything more.
  • mindrobotsmindrobots Posts: 6,506
    edited 2012-10-27 09:55
    You're welcome!
    Discussion is good! You can't always find everything you need and we all learn together this way!!
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-27 12:18
    BTW, I am quite comfortable with the non-standard Forth words as I have had a Propeller chip or two from the very beginning and read the material many times. I do understand the need for the non-standard side.

    Thankfully PropForth provided a 'rather complete' (not completely complete) list of words that I go over every day or two. At this point I do a bit of tutorial word, I read a bit of Forth history, and I go over the ANS Forth and PropForth word lists to see what I know and what I want to explore.

    Maybe in a month or two it will sink into being something that works well. But for now, I am just bumping into one thing after another.
  • prof_brainoprof_braino Posts: 4,313
    edited 2012-10-27 21:55
    As stated, this is not a bug, this is the design of forth in general.

    The extension you want:

    key? - checks if a key is pressed, so this will look and return true is key press.
    key - gets the current key press
    abort? - exits to interpreter quit loop if true.
    : bail key? if  key ESC = abort? then ;  //  pseudo code, the actual code should look similar
    

    the overhead is consistent every pass until the key press, escape bails out of whatever your doing and returns to the command prompt.

    If you are on cog6, you can use bail to allow breaking out of any running loop.

    If you've launched any word in any other loop besides the one running console, you can just send it another command (such as quit) to stop it.

    I tend to add junk like this (non application overhead) when experimenting, but "pros" expect the development words removed from any final application.

    the word "words" lists out all the definitions in tha propforth dictionary from most recent to oldest.
    words
    

    the ones in the beginning of the dictionary (at the bottom of the print out) with the odd looking underscores and prefixes are only used internally, and not generally executed from the command line unless you are redesigning the dictionary (too advanced for me).
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-28 02:19
    Okay, it is a new day.... And it is quite obvious that I stopped just short of learning how to use Cogx. But it might be helpful to mention in the IO Example 2 that it hangs the Propeller until hard reset, and then mention that the next example shows how not to do so.

    I am studying GForth at the same time and it doesn't shut out the console interface. I think one can simply enter Abort to kill the loop in such a situation. It is so true - If you have seen one Forth, you have seen one Forth.

    It seems that a lot of the non-standard words for the Propeller are simply either constants or variables tied to a particular register in the Cogs or an assembler word translated to a Forth word -- not too hard for someone that has used the Propeller a bit. AND, it is very helpful to actually see immediate results to confirm what the Propeller is really doing.

    Yes, yes .... I do know about Words.
    But I am finally using copy and paste to get that complete listing into a spreadsheet or a text file where I can compare it to documentation in the HTML and the Reference List. Words is indeed the bottom-line and using See is helpful if nothing else is available.

    For instances, Waitcnt can be observed in a good configuration or one that ends up with excessive state due to a rollover. Some Propeller students would appreciate being shown directly via an interpreted language, rather than muddle through compile and load.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-28 05:26
    Just another observation about PropForth...
    No 'see' provided. This word allows one to peek at the actual code for the construction of the word that you 'see xxx'. I got very enthused about using this in GForth as I can view exactly what a work I have created contains before I go about modifying it for a better result.

    I suspect youall will just say 'the Forth philosophy is....'

    But is also a very useful word for learners to reverse engineer the whole of Forth. And why learn Forth, if you cannot use it learn more of it?

    I know I am whinning. I have had two cogs doing complicate blinks independently for hours via using Cogx. And I cut and pasted the Words output in order to continue to review PropForth's rather unique dictionary. I am just a bit stumped about looking under the hood.

    I guess I can refer to the address of a word and do a Dump to get it all in machine code.
  • mindrobotsmindrobots Posts: 6,506
    edited 2012-10-28 05:53
    Just another observation about PropForth...
    No 'see' provided. ....

    I suspect youall will just say 'the Forth philosophy is....'

    Aww, and here I've been trying to help out.... :0(

    I'd love to have a see word, I always have the .f files open in an editor so,I can look the words up as I have questions. I don't think it's philosophy here, just nobody has written the word and/or shared it. I think it was Peter (sorry if I'm wrong) who wrote a disassembled a while back. It may be buried in the last PropForth thread. I didn't grab a copy then because I was otherwise occupied (distracted/overwhelmed/frustrated/etc). If I sit down at a real PC, I'll have a go at finding it.

    Did you find the word index on the Wiki? It at least gives you a start by telling you which .f files a word is defined in. I created that to support by brute force way of learning. It makes the initial search easier. Many words are defined in multiple .f files to reduce dependencies on loading things in the proper order or loading stuf you don't need just to get a few words from a module. They are wrapped in if directives to avoid being redefined.

    I still think you are asking good questions. You are a much more thorough and focused learner than I am and that helps me learn and think about things. It's a different language and there's a lot to wrap your head around in the various 'dialects' you are covering.

    I have an 11 years old, you, sir, are NOT whining!!!
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2012-10-28 06:48
    The "see" word is normally only standard in bloated PC Forths. Lets not compare everything to that particular strain. However I had to dig around for it but this is the one that even puts the BEGIN and DO's and some structure back into the decompilation.

    http://forums.parallax.com/showthread.php?138399-Propforth-5.0-is-available-for-download&p=1107790&viewfull=1#post1107790


    PropForth 5 decompiler
    [FONT=courier new]fl
    
    [ifdef Decompiler
    forget Decompiler
    ]
    
    : Decompiler   ." PropForth 5 decompiler V2.1 - Peter Jakacki 120630 " ;
    hex
    
    : is    over = if drop r> W@ execute else r> 2+ >r then ;
    : >w    FFFF and ;
    
    
    \ Define constants for known words with extensions etc
    ' exit wconstant #exit
    ' litw wconstant #litw
    ' litl wconstant #litl
    ' (+loop) wconstant #+loop
    ' (loop) wconstant #loop
    ' 0branch wconstant #0branch
    ' branch wconstant #branch
    ' cq wconstant #cq
    ' dq wconstant #dq
    
    ' _xasm2>1 wconstant #xasm21
    ' _xasm2>0 wconstant #xasm20
    ' _xasm1>1 wconstant #xasm11
    ' _xasm2>1IMM wconstant #xasm2I
    ' _xasm2>flag wconstant #xasmF
    ' _xasm2>flagIMM wconstant #xasmFI
    
    ' lxasm wconstant #lxasm
    ' doconw wconstant #doconw
    ' dovarw wconstant #dovarw
    ' dovarl wconstant #dovarl
    ' doconl wconstant #doconl
    ' 2>r wconstant #do
    
        wvariable indent
        wvariable wcnt
        wvariable dflgs
        
    : +indent    2 indent W+! ;
    : -indent    indent W@ 2- 0 max indent W! ;
    
    : .HEAD    
        dflgs C@ 1 and 
        if 
          dup (dumpm) dflgs C@ 4 and if W@ .word space else drop then
          indent W@ spaces 
        else drop then
    ;
    
    : nl        wcnt W@ if dflgs C@ 1 and 0= if cr indent W@ 4 max spaces then 0 wcnt W! then ;
    : nc        1 wcnt W+! ;
    
        variable labels 1C allot    \ room for 8 longs = address+type each
    : LABEL! \ ( code addr - )     
        w>l labels 
        begin dup W@ dup 
          if   \ code+addr labels (label)
            2 ST@ >w =        \ address match?
            if L! 1            \ yes, replace previous contents and exit
            else  4+ 0            \ no, skip this entry and continue
            then 
          else                \ null entry found, use this one and exit
            drop L! 1            \ 
          then 
        until   
    ; 
    : LABEL? \ ( addr -- code )        \ Find a label and return with it's code or 0 if none
        labels 
        begin
          2dup W@ = 
          if 2+ W@ nip 1  \ ( code 1 )
          else 4+ dup L@ 0= if 2drop 0 1 else 0 then  \ ( 0 1 -OR- addr labels flg )
          then
        until
    ;
    
    : .atrs \ ( atr -- )
        dup 40 and if ."  immediate" then
        20 and if ."  exec" then
    ;
    : .name        pfa>nfa C@++ 1F and bounds do i C@ emit loop nc ;
    
     variable maxref    \ maintain a pointer to the most forward reference in the word begin decompiled
                \ to determine the real end of it (ignore exits before then)
    : .branch    
        dflgs C@ 2 and if ."  >" dup .word then 
        maxref W@ max maxref W! 2+ ;
    
    : .lit        dup 9 > if ." h" then <# #s #> .cstr nc ;
    : =long    alignl dup L@ space .long 4+ ;
    : =word    dup W@ space  .lit 2+ ;
    : =imm        =word =word ;
    : =branch1    over dup W@ + LABEL!    dup W@ over + .branch ;
    
    : .ext  \ ( adr1 pfa -- adr2 )
        #xasm21    is =word
        #xasm20    is =word
        #xasm11    is =word
        #xasm2I is =imm
        #xasmF  is =word
        #xasmFI is =imm
        #litl    is =long
        #lxasm    is =long
        dup    \ these words need a copy of the pfa
        #loop    is =branch1
        #+loop    is =branch1
        #0branch is =branch1
        #branch    is =branch1
        2drop
        ;
    
    
    : branch@  \ ( addr -- addr+2 branch )
        2+ dup W@ over + >w ;
    
    
    : =litw    dflgs C@ 8 and if ." litw " then 2+ dup W@ .lit 2+ ;
    
    : =begin    dup .HEAD nl ." begin " +indent nc ;
    : =until    -indent ." until" nc nl 4 over LABEL! ;
    : =then    dup .HEAD ." thens " -indent nc nl ;
    : =else    ." else "  nc over 2+ 0 swap LABEL! 1 over LABEL! ;
    : =branch    branch@ 2dup > if =until  else =else then .branch ;
    : =0branch    branch@ 2dup > if =until else nl ." if" nc +indent 1 over LABEL! then .branch ; 
    : =do        nl ." do " 2+  +indent ;
    : =loop    ." loop" -indent nc nl 4+ ;
    : =+loop    ." +loop" -indent nc nl 4+ ;
    : =cq        2+ 63 emit 22 emit space dup .cstr 22 emit dup C@ 1+ + ;
    : =dq        2+ 2E emit 22 emit space dup .cstr 22 emit dup C@ 1+ + ;
    
      
    : .LABEL \ ( addr -- )
        LABEL?
        1 is =then
        4 is =begin
        drop
    ;
    : .code \ ( addr -- addr+ )
        dup W@ 
        \ Preprocess structures and literals
        #0branch    is =0branch
        #branch        is =branch
        #litw        is =litw 
        #do        is =do
        #loop        is =loop
        #+loop        is =+loop
        #cq        is =cq
        #dq        is =dq
    
        dup #exit =
          if over 2+ maxref W@ > if drop cr ." ;" 2+ exit then then
        wcnt W@ d8 > if nl then              \ limit length of line
        \ otherwise the default is to print the name and handle any extensions
        dup .name swap 2+ swap .ext 
        ;
    
    : codeword
          dup .HEAD 
        dup 40 bounds do i (dumpm) i 10 bounds do i COG@ .long space 4  +loop 10 +loop
    ;
    
    : _decomp
        4 indent W! nc nl
        dup 
        if  \ must be non-zero otherwise the word does not exist
          dup 800 < 
          if
            codeword
          else \ ( addr -- )
            begin
            alignw
            \ nc
            dup .LABEL
            dup .HEAD
            dup W@ swap .code 
            wcnt W@ if space then  \ add a space after each word but not at the start of a newline
        
            \ determine when to stop decompiling
            swap dup #exit = 2 ST@ maxref W@ > and  \ ( addr+2 pfa flag ) end of code? 
            over #lxasm = or swap #doconw = or  \ ( addr+2 flag ) single operation?
    \        fkey? and 1B = or    \ or if escape key hit
            until
          then
        then
        drop
    ;
    : =dovarw    ." wvariable " .name ;
    : =dovarl    ." variable " .name  ;
    : =doconw    dup 2+ W@ .lit ."  wconstant " .name ;
    : =doconl    dup 2+ alignl L@ .lit ."  constant " .name ;
    
    : .def \ ( 1stpfa -- flg  )
        #dovarw is =dovarw
        #dovarl is =dovarl
        #doconw is =doconw
        #doconl is =doconl
        ." : "
        drop dup .name
        _decomp
    ; 
    : >decomp  \ ( addr -- ) 
        hex 0 maxref W!
        labels 20 0 fill    \ clear labels    
        6 iodis dup _decomp        \ silent listing first 
        10 delms
        6 7 ioconn
        dup >r
        cr 
        dup pfa>nfa C@ 80 and    \ Forth tag?
          if dup W@ .def        \ Yes, process as a Forth definition
          else ." ASMCODE " dup .name codeword drop then 
        r> pfa>nfa C@ .atrs 
        cr cr 
    ;
      
    {
     To enable all addresses and references to be listed with one word per line use: -1 details
     To hide all addresses and references use: 0 details
    }
    : details  dflgs C! ;
        
    : decompall
        ' dup 0= if drop lastnfa else pfa>nfa then 
        begin
          dup nfa>pfa >decomp
          nfa>next dup 0=
              fkey? and dup 20 = if begin fkey? and until then
          1B = or
           until
        drop
    ;
      
    : decomp        \ use in the form "decomp name"
       '  >decomp 
        6 7 ioconn        \ restore in case of errors
        ;
    
    \ ********************************************************
    
    
    
    {
    Usage:
    decomp interpretpad
    
    : interpretpad
        1 >in W! 
        begin bl parseword                                                           
          if pad>in nextword find dup                                                
            if dup -1 =                                                              
              if drop compile?                                                       
                if w, else  execute thens                                            
                0 else  2 = 
                if execute 0 else  compile? 
                  if execute 0 else  pfa>nfa _p? 
                    if ." IMMEDIATE WORD " .strname cr else  drop thens 
                    clearkeys -1 thens 
                  else  drop dup C@++ fisnumber 
                  if C@++ fnumber compile? 
                    if dup 0 hFFFF between 
                      if $C_a_litw w, w, else  $C_a_litl w, l, thens 
                      0 else  compile? 
                      if freedict thens 
                      1 state andnC! _p? 
                      if _udf .strname cr thens 
                      clearkeys -1 thens 
                    else  -1 thens 
                  until
                
    ;
    }
    \ ****************** END ********************
    
    [/FONT]
    
  • mindrobotsmindrobots Posts: 6,506
    edited 2012-10-28 06:57
    Ha! Found it!! Peter Jakacki's PropForth Decompiler is here.

    EDIT: There's a newer version on the PropForth Wiki, here. (I know, read the documentation!! I should know better!!)

    You realize you've forced me to hook up a Propeller and play.....sadly, something I haven't done in months.

    I cut and pasted his .fth file into a fresh install of PropForth 5.02 (or .03 or whatever the last pre-release was)

    Once loaded, I did a decomp cogx, since we've been talking about that word. and got this:
    Prop0 Cog6 ok
    decomp cogx
    
    : cogx
     io 2+ W@ rot2 cogio io 2+ W! .cstr cr io 2+ W!
    ;
    

    When I look in the PropForth .f files, I find this code for cogx:
    : cogx
        io 2+ W@
        rot2 cogio io 2+ W!
        .cstr cr
        io 2+ W!
    ;
    

    in PropForthStartKernel.f

    It looks like a winner as far as the decompiler goes! Yay, Peter!!

    If you want, you can always rename the word see, so it's more standard to the Forths you are working with.

    Thank you for making me find this, it will be a much nicer tool than digging through the source code to find words. I'll have to include it in my debug file.

    It's also nice to get to play with PF again, I may need to spend some time getting reacquainted with my old friend, today! Football and Forth Sunday!!
  • prof_brainoprof_braino Posts: 4,313
    edited 2012-10-28 06:59
    Just another observation about PropForth...
    No 'see' provided. .

    ... it was provided in the beginning, but nobody used it, and nobody seemed to want it, and Sal found that he didn't need it. And we must remove unwanted code.

    BUT since you asked for it, we can see about putting it back, maybe in the developer extensions (so that are only loaded in dev, and are not automatically included in the kernel?).

    Please open an issue requesting this function.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-28 08:13
    Thanks. I really don't mean to be a crank.
    Yes, I am using GForth that is likely a 'big bloated Forth' to help me along. I don't have any insight into what other's used to learn Forth, but if you learned way back in '79, it may not be useful to a newcomer. In some cases, GForth merely provides machine code when 'see' is used, but I can at least review my own definitions to see what I've done.

    So to get up to speed, I am studying Forth on the Propeller as PropForth and working with the GForth tutorials for ANS Forth at the same time. Back 1980, I was married to a bar stool in Eugene, Oregon, in a fog of Blitz beer, and I really missed all this.

    Having a .f file with 'see' is extremely useful to me at this point. I just tried to preview all the words listed by Words and there are even more than I expected. I realize space is an issue, but so is providing useful tools for new learners to develop their own ability to discover Forth.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-28 09:21
    It is rather silly of me to not notice that I can read the original .f file for the dictionary and I don't have to use 'see'. But I have been used to full featured computers rather than these work arounds for small systems.

    Thank's again to everyone for being helpful.

    In many ways Forth reminds me of my early days with studying Chinese characters. One just has to keep cramming in characters until the brain catches up with associating meaning to them. Since even a basic reader has to have 2000 characters in order to read childrens books and easy stuff, one tends to fumble around a lot in the beginning.

    BTW, philosophy is too deep for me.
  • mindrobotsmindrobots Posts: 6,506
    edited 2012-10-28 11:11
    ..these work arounds for small systems.

    Let's say "optimized for smaller footprint implementations", ok? :smile:
    One just has to keep cramming in characters until the brain catches up with associating meaning to them. Since even a basic reader has to have 2000 characters in order to read childrens books and easy stuff, one tends to fumble around a lot in the beginning.

    I tried to learn Russian a few years back (my hardest language attempt). It's always humbling when the children you see in a country are able to tackle their native tongues. Maybe we should train programmers at a very young age!

    I've become a big fan of "decomp" today. It's a wonderful tool to have available and sure beats reading the .f files.

    Finally, congratulations on your "divorce"!!
  • prof_brainoprof_braino Posts: 4,313
    edited 2012-10-28 13:09
    mindrobots wrote: »
    I tried to learn Russian a few years back (my hardest language attempt). ... Maybe we should train programmers at a very young age!

    Or take your time, instead of rushin'.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-28 14:09
    How about "PHILOSOPHICALLY optimized for smaller footprint implementations", ok? :smile:

    My impression of Forth is that it is very much a computer language equivalent to Esperanto.

    Esperanto is a language that everyone has an equal input in creating as no one source can claim to be its origin. But by taking such and approach, nobody really knows what Esperanto is and only a few zealous souls choose to learn it.

    Tyranny has a bit of stabilizing effect on language use.

    Russian, Chinese, or whatever - kids are much more able to assimilated a new language fully and quickly than adults. Actual changes in the brain at puberty seem to slow down the whole process there after. And changing to a Cryllic alphabet or Chinese characters really force the learner to use parts of the brain that they haven't used for language before.

    Divorced the bar stool in '83.
  • prof_brainoprof_braino Posts: 4,313
    edited 2012-10-28 17:31
    Opened issue 164 for bringing SEE, DECOMPILE, and DISASSEMBLE up to 5.3.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-29 02:00
    Thanks for you prompt efforts. I really feel that too much attention is often placed on my opinions. But in this case, the use of these words will ease the need to write a lot of documentation for new users.

    I hope these words will bring more new users to you. Writing documentation is endless tedious and rarely up-to-date. One has to think, think, thing; then write and rewrite.

    I changed the thread heading to 'imaginary bug' and we have cleared up my misperceptions about the endless loop in PropForth. I can get other cogs to commit to an endless loop while having the terminal interface remain up for uncommitted cogs. But it seems the only way to break the loop is to kill the committed Cog. Maybe I am wrong about this.

    The 'begin... ....until' endless loop is a great way to explore Cog control without having to read (or write) documentation about what is happening. I may yet learn to break into the loop and have the stack move onto other items - such as providing a message that the loop has been broken. Now, I am trying to learn when and how Abort and Abort? work.
  • prof_brainoprof_braino Posts: 4,313
    edited 2012-10-29 06:19
    Thanks for you prompt efforts. I really feel that too much attention is often placed on my opinions.

    d how Abort and Abort? work.

    our model is that the docs are driven by user questions. (me simply writing on random topic did not appear to yeild benefit). so you questions to date have been a primary driver, please do not slow down. in fact, if you were to create a page on the wiki for each "discovery" it would benefit many. your point of view is much closer to a new user than mine.

    abort end any yask, and return to a bare command line running the interpreter. abort? consumes one item from the stack, if true (non zero) it aborts, otherwise does not
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-29 08:45
    Wiki? Where is the Wiki? That might be a good idea.

    These Forth threads have been getting rather long. It concerns me that their winding nature is rather counter-productive to newcomers. I know from my own experience that when threads get too long, it shuts out a lot of readership.

    To avoid that, I started doing some Parallax Blog entries of a more detailed nature about beginning Forth on the Propeller. The first two entries have been rather general.

    The First - Mostly about my own approach of learning GForth and PropForth in parallael and the importance of reading the most up-to-date version of "Starting Forth" if you have never done so.

    The Second - A survey of the rather diverse world of terminal emulation programs that are avaiable for free. I suspect that many new users feel terminal emulation programs are too complicated or they feel they must buy the best or the don't know how to get one that is well-supported with tutorials and a large user base.

    The above blog entries were rather general in nature. I have a lot I am trying to grasp. For the most part - the role of the Dictionary is central, so how do I come to terms with what it is. What do I need to know about the Pad? What is going on after a word is created? Understanding that Forth uses colon/semi-colon words, constants (which can be doubled), variables (which also can be doubled), and create (as a means to set aside larger spaces for arrays, etc.).

    Somehow, that all may get into a Third Blog. But Wiki's for PropForth may be very rewarding - more objective and modular to edit.

    And there are also the simple problems of learning one's ways around the existing resources -- such as the .f files and the actual .spin files for PropForth. TachyonForth seems to want to release binaries instead, but I am seeing some convienence in having the .f files to read if their is not other documentation for whatever I am pondering.

    I still am reading a bit of history of the evolution of Forth and some overview material on Forth -- such as the Wikipedia entry for Forth. These things I do so that I don't just get lost in one version. I thinking the history is very important in this language as changes pull away words and provide new ones in a rather mysterious way if you don't know something of the history.

    See, decompile, and words of related functionality are extremely helpful to me right now and I hope that they will continue to provide a big assistance.

    But at some point, more overview of what PropForth is and how it compares to the 'big bloated Forths' is going to be helpful. Already, I have become rather dependent on features in GForth that make typing very easy. These small lean, mean Forths for micro-controllers cannot afford to have some rather nice options to automatically retype and to fill in the rest of a word when you don't remember it all.

    I don't expect the small Forths to try to provide these features, but knowing about the contrast keeps everything in perspective. PropForth really is more about managing 32 i/o pins, while GForth is all about doing bigger projects on a complete OS. Nonetheless, Forth will always have the heartbeat of a number cruncher. I can do some rather dramatic 32bit calculations.

    Lots to study, lots to learn. But as far as Prof_Braino and Sal, I don't really want them working hard just to appeal me. Other people need to present themselves and dare to ask the dumb questions. I will learn even more from other people posting.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-29 08:52
    abort end any yask, and return to a bare command line running the interpreter. abort? consumes one item from the stack, if true (non zero) it aborts, otherwise does not

    My guess is that translates into "The word 'abort' ends any task and returns to a bare command line running the interpreter. While the word 'abort?' consumes one item from the stack and if true (a non-zero), it aborts, otherwise it does not.

    Sorry to be so pedantic, the combination of typos and loose grammar in the beginning of that entry make it rather hard to decypher. You can copy and paste that snippet. Put it in your wiki and smoke it... so to speak.

    Still, if you call a loop with Begin, you have to include your own 'abort?' within the loop or you will never get this feature to work. The Begin... loop does pull a value off the stack to decide to keep going. If just se to 0, the infinite loop shuts out all until you resent the Cog - plain and simple. I have no idea about other loops and the 'abort' or 'abort?'. I will have to explore.

    On other fronts, I saw a request in the Propeller Forum of how to get the output of a simple button down condition to a serial port in SPIN today. OMG, the amount of code to do that is rather huge and complex; while Forth seems likely to be so easy and short for such a task. It is hard not to jump in and say 'Use PropForth' and it is just that and that and there you go.
  • prof_brainoprof_braino Posts: 4,313
    edited 2012-10-29 09:06
    if you can decypher GOTERM from the go language support instructions...

    goterm provides the OS command line support. so you can scroll and edit the command line history like in linux. i meant to add this to the dev extensions for jupiterace; it always takes too much memory until we require SD and that breaks the "runs on any prop chip" rule so was not added to the standard kernels.

    please try to create/edit pages on the wiki, you have many useful insights we want to capture
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-29 09:28
    I am not using the JupiterACE model because of two obstacles. The VGA I have for it is a bit tempermental. I have to clean the interior about every six months to get good pictures. Besides, I have the Propeller ProtoBoard in plastic tub with power supply and usb cable. That goes to Starbucks with me and my netbook to work out PropForth.

    In this modern world, gadgets have to travel with you.

    I have to find out what GOTERM is. I found this ==> http://code.google.com/p/propforth/wiki/GoSetup20120511
    But I am not up to speed (once again).
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-29 09:33
    I found Go and took a peek inside the zip file. It is for Windows and I am one of those nasty Linux users. Porting it over would be a rather huge distraction for me. I am using Minicom and PropForth is just making me improve my typing accuracy.
  • prof_brainoprof_braino Posts: 4,313
    edited 2012-10-29 13:55
    sorry, this is from a phone

    i forgot the posted GO is the windows prototype. it all works the same on linux.

    we should have the final v5.3 shortly, i know i've been saying this for months
Sign In or Register to comment.