Shop OBEX P1 Docs P2 Docs Learn Events
"Forth of the Forth" Challenge (in December) — Parallax Forums

"Forth of the Forth" Challenge (in December)

Peter JakackiPeter Jakacki Posts: 10,193
edited 2012-12-16 05:54 in Propeller 1
NEW LINK! Forth of the Forth Challenge page

As mentioned in mindrobots thread "Forthers-Thanksgiving-Challenge-it-s-all-about-the-projects-baby!!!" I am upping the ante by also including my own challenge which anyone can enter (except myself) and I am offering not only a 1st prize but also a 2nd and a 3rd ...... and of course we have to have a 4th prize.

Since this is the inaugural challenge the deadline for entries will be the 4th of December instead of April as I am hoping to do this again next year (with P2 hopefully). As long as the entry is in before the "4th" is over everywhere in the world (I think that's Honolulu time). The conditions for the inaugural challenge will be kept simple and so as not to add anything or take anything away from what I previously stated in the Thanksgiving Challenge thread I am copying the conditions here:
Conditions are that this is based around a Propeller chip of course and that you use any Forth for the application code with assembler kept to an absolute minimum (remember, we are showcasing Forth). The application should be stand-alone and ready to run from power-up. Points given for readability so factor out those functions into smaller words and choose a name that describes it well and fits in well with how it is used. Additional points for keeping extraneous hardware to a minimum.

The time frame until Thanksgiving is probably a little short for this particular challenge so how about we set it for the 'Forth" of December 2012? Now if we had another one for the "Forth of the Forth" then that would be a very easy date to remember. We will see how we go with this one first.

Since time is short I won't impose any more conditions, just get to it and may the Forth be with you!

1st Prize is a P1145 "SongBox" board with a "Puppy Prop" module, QVGA Touch screen, USB and Bluetooth modules, matched enclosure and 4GB microSD and 4GB SD cards. The board includes stereo jacks for audio in (Sigma Delta) and audio out as well as RS-485 and USB style PS/2 connector. Power is either via the USB module or a micro USB socket.
P1145-TFT-m.jpg


Details of the 2nd, 3rd, and 4th prizes will be appended to this post shortly but they will all be Propeller products of some kind.

BTW, even if you have already submitted your project to the Thanksgiving Challenge, feel free to enter it in the "Forth of the Forth" challenge.
1024 x 909 - 159K
«134

Comments

  • mindrobotsmindrobots Posts: 6,506
    edited 2012-11-20 06:06
    Very cool, Peter!

    Great prizes! Hey, that looks almost like a commercial project :0) is there any way the losers would be able to buy one of the sweet Song Boxes???

    Two Forth contests, folks! That should be enough to bring the Forth Faithful ut of the woods and maybe also draw some non-Forthers into the pool!!
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2012-11-20 06:23
    mindrobots wrote: »
    Very cool, Peter!

    Great prizes! Hey, that looks almost like a commercial project :0) is there any way the losers would be able to buy one of the sweet Song Boxes???

    Two Forth contests, folks! That should be enough to bring the Forth Faithful ut of the woods and maybe also draw some non-Forthers into the pool!!
    Since this is not one of my commercial products (but it could be) I am free to offer this as a "hobby" product then (much cheaper). I originally did this just to play with audio a little bit more and it is meant to drive a 20x4 character LCD normally with an external keypad but this version will have the adaptor upgrade so the touch screen can be used instead. I've also run Pelco PTZ cameras from the RS-485 too. Anyway, it's a fun little board so I will see what I can do about making more of them available although I'm not really setup for handling small orders but it's something I'm working on from a "fun" aspect.

    BTW, have you noticed that the top 6 posts in this forum are all about Forth!
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2012-11-28 19:32
    Just a reminder that the 4th is looming closer so get your projects ready. If it helps then please submit them here by or on the 4th of December and I will allow a little more time for you to complete it if it is close to being completed. Remember there are 4 prizes so you are bound to win something cool. Either make it something functional and useful or make it interesting but showcase Forth in terms of ease of development and how much satisfaction you got from doing it this way and of course make it readable for the masses. Use Brian's entry to the "Thanksgiving" challenge as a guide, it's useful and it's readable, and makes it look easy.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-11-29 06:20
    Well, I seem to still be waiting for a fresh inkjet cartridge for my Chopstick printer that were supposed to be available in two business days. So I will just have to come up with something else.

    But fear not, I am pretty sure that I can come up with something interesting. I might even finish the project this time.
  • mindrobotsmindrobots Posts: 6,506
    edited 2012-11-30 19:05
    My project is taking shape enough that I will announce my intentions to accept this challenge!!

    I wanted a project that would fit the seen by the majority of the Forumistas....not a serious tool meant for not very serious projects...or something that is mostly a figment of the imagination and as useful as most figments.

    So, with a PPDB and Tachyon, I've come up with the Single Digit Clock!!! Yes, to prove the economy of Forth code, I'm making a clock with a single digit! It was going to be a QuickStart with a single large digit but delivery circumstance and Radio Shack's complete lack of LED displays have caused me to embrace my PPDB.

    I've got the display working and just need to either get the DS1302 RTC on the PPDB working under Tachyon or else just let the Propeller keep time....I mean really, how much accuracy do you need with only one digit??

    Video as soon as possible.

    Come on, folks, time is running out, it's almost the FORTH of December!!!!!! The deadline approaches!!!!

    Don't fear though, if you miss this Forth challenge, there's another just around the corner (maybe even prizes if I find a sponsor).....I promise it will be TIMELY!!
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2012-11-30 19:40
    mindrobots wrote: »
    My project is taking shape enough that I will announce my intentions to accept this challenge!!

    I wanted a project that would fit the seen by the majority of the Forumistas....not a serious tool meant for not very serious projects...or something that is mostly a figment of the imagination and as useful as most figments.

    So, with a PPDB and Tachyon, I've come up with the Single Digit Clock!!! Yes, to prove the economy of Forth code, I'm making a clock with a single digit! It was going to be a QuickStart with a single large digit but delivery circumstance and Radio Shack's complete lack of LED displays have caused me to embrace my PPDB.

    I've got the display working and just need to either get the DS1302 RTC on the PPDB working under Tachyon or else just let the Propeller keep time....I mean really, how much accuracy do you need with only one digit??

    Video as soon as possible.

    Come on, folks, time is running out, it's almost the FORTH of December!!!!!! The deadline approaches!!!!

    Don't fear though, if you miss this Forth challenge, there's another just around the corner (maybe even prizes if I find a sponsor).....I promise it will be TIMELY!!

    Is this one of those ones where you have to move your head from side to side or walk past to see it out the corner of your eye!!? Or is it in fact a count-down timer for the 21st? That would be timely!
  • mindrobotsmindrobots Posts: 6,506
    edited 2012-11-30 19:45
    Is this one of those ones where you have to move your head from side to side or walk past to see it out the corner of your eye!!? Or is it in fact a count-down timer for the 21st? That would be timely!

    Now, now, we mustn't ruin the surprise!!!

    By the way, I finally have my Tachyon environment squared away and it's brilliant!! The LOOKUP word is near genius!!

    Hopefully, my project write up will be a good tutorials in application development in Forth....or not.

    Yes, timely indeed!! :0)
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-12-01 08:38
    Well it is going to be a squeaker for me to get my contribution in. I've had a fewe set backs again, but I am recovering from them and plodding on. I really don't know if my entry will be another unfinished attempt and unworthy of a prize.

    This is NOT going to be a continuation of the chopstick printer. And it will be in PropForth. And I hope it to be useful and informative to new PropForth users.

    Anyway, we need more contestants or I will win a prize just by the default of too few entires. At this point, even if I enter, there will be two prizes that go unclaimed.

    Forth is fast, fun, and furious. Or maybe I am just furious and Forth is fast and fun.

    Come Forth you undeclared.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-12-02 08:17
    Midnight Honolulu TIme on December 4th. I have to double check how that works out in Taiwan. I think I am actually 18 hours ahead, so 6am is my deadline the same day.

    Working hard to pull this off. It is a lot of testing and writing.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2012-12-02 17:08
    Midnight Honolulu TIme on December 4th. I have to double check how that works out in Taiwan. I think I am actually 18 hours ahead, so 6am is my deadline the same day.

    Working hard to pull this off. It is a lot of testing and writing.

    Midway is an hour earlier (GMT-11) than Honolulu even so it might be one of the the last places where it would still be the 4th of December when every other place is the 5th. The point is, just submit your entry by the 4th while it is still the 4th somewhere in the world. For instance you are in Taiwan which is GMT+8 so therefore you have another 19 hours after the the 4th in Taiwan to submit an entry (I think that's right). If your project is near completion but not quite finished then submit it anyway, you will be allowed a little bit of extra time to complete it. This isn't a rigid regulated by law competition but a Forth for fun competition, remember, Forth is fun. Try to polish the code to increase your chances. That is besides being functional it should have form, and a certain "elegance" either in it's simplicity and clarity or in it's innovate approach to the task for instance.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-12-02 17:56
    Almost feels like cheating, but you are the one that makes the rules. That gives me a bit of a reprieve if I need it. And I don't have to stay up all night to get the project done. But I just may submit something 24 hours early.

    I suffered a few rather interesting and unexpected setbacks and sorted out some rather gnarly problems. In the end, there may not be much to show for it, but the competitions are working their magic as learning experiences.

    Of course everyone now knows that Parallax is running yet another contest with even more prizes that has deadline near Christmas , Dec 20th.

    http://forums.parallax.com/showthread.php?144156-CONTEST-Hack-The-Halls!
  • mindrobotsmindrobots Posts: 6,506
    edited 2012-12-02 18:04
    Oooh, oooh, I may be having another challenge before the end of the year..or world...oh, bother, it all gets so confusing sometimes! BUT, it will be TIMELY!!
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-12-03 10:08
    Hmmm... 2:04 am December 4th in old Taiwan.
    I just finally got the last of the PropForth code to behave in actual testing.

    So it seems, that I just have to type up a few corrections and this is ready to go. I just may make that 6am deadline and comply with 12 Midnight Honolulu time.

    But now that I think of it, the guys in the USA have an advantage over me, it is still only December 3rd.

    So be it. At least it is nice to finish something.
  • mindrobotsmindrobots Posts: 6,506
    edited 2012-12-03 10:39
    13:37 PM, December 3rd in old Ohio! :lol:

    We need staggered start times!
  • Heater.Heater. Posts: 21,230
    edited 2012-12-03 11:45
    Is it possible you could fix the spelling mistake in the thread title?
    Until Forth becomes very famous there is no "Forth of December" on the 4th day.
  • Dave HeinDave Hein Posts: 6,347
    edited 2012-12-03 12:18
    Heater, it is pointless to try to reason with someone after they have been assimilated. :) However, I am wondering whether the deadline is at the beginning of the 4th, or at the end of the 4th. Technically, a new day starts at midnight, so that would indicate that the deadline occurs at the first second on the 4th. But I guess midnight is normally used to mean the end of the day, so maybe the deadline occurs after the last second on the 4th.

    It probably doesn't matter much since there are 4 prizes, and up until now there have only been 3 responders to this thread. So you and I can battle it out for 4th place.
  • Heater.Heater. Posts: 21,230
    edited 2012-12-03 12:33
    Dave,

    So, if you enter you win, assuming no one else pops up. I'll let you take the honors for our non-participation:)
  • Dave HeinDave Hein Posts: 6,347
    edited 2012-12-03 12:49
    OK, I officially enter my toggle.fth program. It only took me 2 months to write it ( plus the Forth interpreter that it runs under :) ).
    \ ############################################################################
    \ # toggle.fth - This program starts up a Forth cog that toggles P15
    \ #
    \ # Copyright (c) 2012 Dave Hein
    \ # MIT Licensed
    \ ############################################################################
    
    create cogstack  80 allot     \ Allocate data stack space
    create cogreturn 80 allot     \ Allocate return stack space
    create delaycnt  80000000 ,   \ This variable controls the blink rate
    
    hex
    \ This word toggles bit P15 every "delaycnt" cycles
    : toggle
      8000 dirasetbit cnt@        \ Set P15 for output and get CNT
      begin
        delaycnt @ + waitcnt      \ Wait "delaycnt" cycles
        8000 outasetbit           \ Set P15
        delaycnt @ + waitcnt      \ Wait "delaycnt" cycles
        8000 outaclrbit           \ Clear P15
        false                     \ Load FALSE so UNTIL loops back
      until ;
    decimal
    
    create cogconfig              \ Forth cog config structure
      ' toggle >body ,            \ Get execution token for TOGGLE
      cogstack ,                  \ Initial value of stack ptr
      cogstack ,                  \ Empty value for stack ptr
      cogreturn ,                 \ Initial value of return ptr
      cogreturn ,                 \ Empty value for return ptr
    
    \ This word starts a cog running the TOGGLE word
    : starttoggle forth @ cogconfig cognew ;
    
    \ +--------------------------------------------------------------------
    \ |  TERMS OF USE: MIT License
    \ +--------------------------------------------------------------------
    \ Permission is hereby granted, free of charge, to any person obtaining
    \ a copy of this software and associated documentation files
    \ (the "Software"), to deal in the Software without restriction,
    \ including without limitation the rights to use, copy, modify, merge,
    \ publish, distribute, sublicense, and/or sell copies of the Software,
    \ and to permit persons to whom the Software is furnished to do so,
    \ subject to the following conditions:
    \ 
    \ The above copyright notice and this permission notice shall be
    \ included in all copies or substantial portions of the Software.
    \ 
    \ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    \ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    \ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
    \ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
    \ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
    \ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    \ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    \ +------------------------------------------------------------------
    
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2012-12-03 17:29
    Hi guys, where are the entries? It's not quite midday here so there is up to 31.5 hours still remaining as it is now 2:30pm on the 3rd in Midway. Remember we are looking for stand-alone "applications" so it should do something useful :)

    @Dave: that's a lot of code just to toggle a pin!! This is how we blink an LED in another cog in Tachyon:
    : BLINKY BEGIN #12 PINSET 100d ms #12 PINCLR 100d ms AGAIN ;
    ' BLINKY 4 RUN
  • mindrobotsmindrobots Posts: 6,506
    edited 2012-12-03 18:13
    Well, it's 9:07PM EST her in Ohio, USA!

    My display words are working fine, I can decompose and compose number (pack and unpack) but for some reason my DS1302 just isn't working.

    I'm sure it's something silly or something I don't understand about Tachyon, yet.

    If anyone cares to look and/or is familiar with the DS1302, any suggestions would be appreciated.
    \
    \ DS1302 on PPDB
    \ Routines based on SPIN Example
    \
    \ CE on Pin 17
    \ I/O on Pin 18
    \ CLK on Pin 19
    \
    \ DS1302 Command codes
    
    %10000000 CONSTANT rdsecreg
    %10000001 CONSTANT wrtsecreg
    %10000010 CONSTANT rdminreg
    %10000011 CONSTANT wrtminreg
    %10000100 CONSTANT rdhrsreg
    %10000101 CONSTANT wrthrsreg
    %10000110 CONSTANT rddatereg
    %10000111 CONSTANT wrtdatereg
    %10001000 CONSTANT rdmonreg
    %10001001 CONSTANT wrtmonreg
    %10001100 CONSTANT rdyrreg
    %10001101 CONSTANT wrtyrreg
    %10001110 CONSTANT rdctrlreg
    %10001111 CONSTANT wrtctrlreg
    %10111110 CONSTANT rdbrstreg
    %10111111 CONSTANT wrtbrstreg
    
    DECIMAL
    
    : DS1302_ENABLE ( pin -- )
        19 MASK OUTCLR  
          MASK OUTSET ;
      
    : DS1302_DISABLE ( pin -- )
        MASK OUTCLR ;
        
    : DS1302! ( data -- )
        18 MASK OUTPUTS     \ set I/O PIN to OUTPUT
        18 MASK SWAP     \ set up the I/O pin on DS1302 (pinmask data -- )
        19 MASK OUTCLR        \ force CLK lo
        8 FOR SHROUT
            19 MASK OUTSET
            NOP
            19 MASK OUTCLR 
            NEXT
        DROP
        DROP    
        ;
        
    : DS1302@ ( -- data )
        18 MASK INPUTS \ set  I/O PIN to INPUT
        18 MASK 
        0
        8 FOR SHRINP
            19 MASK OUTSET
            NOP
            19 MASK OUTCLR
            NEXT
        SWAP
        DROP    
            ;
            
    : SET_SECONDS ( packed -- )
        wrtsecreg DS1302!
        DS1302!
        ;
    : GET_SECONDS ( -- packed )
        rdsecreg DS1302!
        DS1302@
        ;
                
    

    Even with a single digit clock, I can tell time is running out!!
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2012-12-03 18:21
    mindrobots wrote: »
    Well, it's 9:07PM EST her in Ohio, USA!

    My display words are working fine, I can decompose and compose number (pack and unpack) but for some reason my DS1302 just isn't working.

    I'm sure it's something silly or something I don't understand about Tachyon, yet.

    If anyone cares to look and/or is familiar with the DS1302, any suggestions would be appreciated.
    \
    \ DS1302 on PPDB
    \ Routines based on SPIN Example
    \
    \ CE on Pin 17
    \ I/O on Pin 18
    \ CLK on Pin 19
    \
    \ DS1302 Command codes
    
    000000 CONSTANT rdsecreg
    000001 CONSTANT wrtsecreg
    000010 CONSTANT rdminreg
    000011 CONSTANT wrtminreg
    000100 CONSTANT rdhrsreg
    000101 CONSTANT wrthrsreg
    000110 CONSTANT rddatereg
    000111 CONSTANT wrtdatereg
    001000 CONSTANT rdmonreg
    001001 CONSTANT wrtmonreg
    001100 CONSTANT rdyrreg
    001101 CONSTANT wrtyrreg
    001110 CONSTANT rdctrlreg
    001111 CONSTANT wrtctrlreg
    111110 CONSTANT rdbrstreg
    111111 CONSTANT wrtbrstreg
    
    DECIMAL
    
    : DS1302_ENABLE ( pin -- )
        19 MASK OUTCLR  
          MASK OUTSET ;
      
    : DS1302_DISABLE ( pin -- )
        MASK OUTCLR ;
        
    : DS1302! ( data -- )
        18 MASK OUTPUTS     \ set I/O PIN to OUTPUT
        18 MASK SWAP     \ set up the I/O pin on DS1302 (pinmask data -- )
        19 MASK OUTCLR        \ force CLK lo
        8 FOR SHROUT
            19 MASK OUTSET
            NOP
            19 MASK OUTCLR 
            NEXT
        DROP
        DROP    
        ;
        
    : DS1302@ ( -- data )
        18 MASK INPUTS \ set  I/O PIN to INPUT
        18 MASK 
        0
        8 FOR SHRINP
            19 MASK OUTSET
            NOP
            19 MASK OUTCLR
            NEXT
        SWAP
        DROP    
            ;
            
    : SET_SECONDS ( packed -- )
        wrtsecreg DS1302!
        DS1302!
        ;
    : GET_SECONDS ( -- packed )
        rdsecreg DS1302!
        DS1302@
        ;
                
    

    Even with a single digit clock, I can tell time is running out!!

    You have to stop thinking in PropForth when you code in Tachyon. Tachyon is much cleaner and simpler if you just use the Forth.

    Firstly:

    Use constants for the I/O and define as masks in the first place
    #P17 |< CONSTANT CE
    #P18 |< CONSTANT I/O
    #P19 |< CONSTANT CLK

    Second:
    : DS1302! ( data -- )
    I/O OUTPUTS \ set I/O PIN to OUTPUT (normally redundant but needed for SHROUT)
    I/O SWAP \ set up the I/O pin on DS1302 (pinmask data -- )
    CLK OUTCLR \ force CLK lo
    8 FOR SHROUT
    CLK OUTSET
    NOP
    CLK OUTCLR
    NEXT
    2DROP
    ;

    Thirdly:
    : DS1302@ ( -- data )
    I/O DUP INPUTS \ set I/O PIN to INPUT
    0 ( mask data -- )
    8 FOR SHRINP
    CLK OUTSET
    NOP
    CLK OUTCLR
    NEXT
    NIP
    ;

    Forth'ly:
    Where are you using the chip enable? BTW, Don't bother defining words for these when they are very simple operations. Either say:
    CE OUTCLR or CE OUTSET

    Now, I'll leave the rest up to you...

    BTW:
    DS1302 TIMING.jpg


    1024 x 656 - 60K
  • Brian RileyBrian Riley Posts: 626
    edited 2012-12-03 22:13
    I have two entries the first is of course my newer and improved PumpTimer located but ONE CLICK away lest Peter get a thumb cramp.


    My second entry is a joint entry of Nick Lordi and myself. We started back in October. Nick presented me with a basic design for a breakout board for Propeller Platform for microMega's 64 bit Floating Point Co-process a small toolbox 2 dozen words to manipulate it.''

    Our project is the completion of the breakout board, containing the FPU64, a Digilent PmodSF2 16 megabyte high speed serial flash, and a Parallax uSD card slot.

    IMG_1272.jpg


    That done, the rest of the project is I have the FPU and the uSD running and about a third of the FPU's vast power evaluated .

    I have become something of a Tachyon Forth Evangelista with this project. Even the 30% of the chip I have explored would have taken 2-3 times longer on any other Forth. Being able to build and run loops on the fly saves enormous time.

    Below is the loadmap and all the files are in the zip


      Propeller .:.:--TACHYON--:.:. Forth V21121114.1330
    
    NAMES:  $5BB1...7499 for 6376 (17644 bytes added) with 21061 bytes free
    CODE:   $0000...357F for 7319 (0731 bytes added) with 19073 bytes free
    CALLS:  0447 vectors free
    
    MODULES LOADED:
    34F5: BBR.fth             Brian's Shortcuts - 20121203.2100
    32A4: uMfpu64.fth         Floating Point Math Chip Toolkit - 20121203.1900
    2FF7: FPU64opcodes.fth    List of opcodes as constants - 20121203.2000
    2F50: LCD.fth             small serial LCD toolset on pin 6 - 20121203.1200
    279E: SDCARDmod.fth       SD CARD Toolkit - 121023.2200
    2713: SPI.fth             Generic SPI Driver - 20121021.0000
    1840: EXTEND.fth          Primary extensions to TACHYON kernel - 121113.1200
    ----------------------------------------------------------------
    


    It as so easy to do things with TF that I made a shout out for "the other forth'

    IMG_1270.jpg


    My newest Propeller Platform Through Hole board, you may remember, has two Atmel megabit EEPROMs giving a total of 256KB, or in other words slots for 8 boot images. Now slot 0 ($0000) is the default boot. Slot 1 ($8000) is used by Peter''s BACKUP/RESTORE commands ( the short story is, if you do a backup and TF detects you have at least a 64K EEPROM, it, first, copies the boot image in slot 0 to slot 1, then writes the new boot image from RAM to slot 0. The RESTORE command will restore the last image from slot 1 to slot 0 and reboot.

    Now, the PropPlat TH has six(6) more slots, 2 thru 7 ($10000 through $38000) and TF has a copy EEPROM command ... EECOPY ( src dest bytes -- ) . Now both of these projects involved multiple files and changing one file from late in the load can be a real drag. RESTORE lets you back up one step. BUt judicious use of EECOPY gives you the power to step back to any of six milestones for the price of two dozen seconds of EECOPY time.

    This also saved me much time in copy/pasting that didn't have to be done.
    1024 x 768 - 119K
    1024 x 491 - 54K
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-12-04 00:47
    Okay, here is my contest entry. It is a suppliment to PropForth v5.03's Tutorial 3.2 that reaches out to the real work and troubleshoots serial connections. I have to admit that it is much longer than the original tutorial, but it provides a lot more practical information.

    Hopefully, the added practical information will make more users interested in trying PropForth.

    Peter tries to claim that Tachyon is easier to use, but I am not yet sure. It just might be that PropForth is just struggling to make their documents something other than 'dry as a bone' technical presentations.

    In sum, it has gotta be fun and Tachyon does seem to be ahead in making it so.


    Lots of time re-reading and re-typing. All the code has been tested with real hardware.

    The bottom-line is still that I like to use my Propeller intereactively.... learning is more interesting.
  • Dave HeinDave Hein Posts: 6,347
    edited 2012-12-04 06:24
    Hi guys, where are the entries? It's not quite midday here so there is up to 31.5 hours still remaining as it is now 2:30pm on the 3rd in Midway. Remember we are looking for stand-alone "applications" so it should do something useful :)

    @Dave: that's a lot of code just to toggle a pin!! This is how we blink an LED in another cog in Tachyon:
    : BLINKY BEGIN #12 PINSET 100d ms #12 PINCLR 100d ms AGAIN ;
    ' BLINKY 4 RUN
    I withdraw my submission to the contest.
  • David BetzDavid Betz Posts: 14,516
    edited 2012-12-04 06:38
    Hi guys, where are the entries? It's not quite midday here so there is up to 31.5 hours still remaining as it is now 2:30pm on the 3rd in Midway. Remember we are looking for stand-alone "applications" so it should do something useful :)

    @Dave: that's a lot of code just to toggle a pin!! This is how we blink an LED in another cog in Tachyon:
    : BLINKY BEGIN #12 PINSET 100d ms #12 PINCLR 100d ms AGAIN ;
    ' BLINKY 4 RUN
    Seems like Dave's code for blinking an LED is mostly longer because his Forth interpreter offers more flexiblity in setting up execution on another COG. How does Tachyon decide what size stacks to use and where to place them?
  • Dave HeinDave Hein Posts: 6,347
    edited 2012-12-04 06:50
    My code also contains a few comments. It's intended to demonstrate how to start up a pfth Forth cog, and I wasn't trying to minimize the amount of code required. If that was my intent I could have created a few words that hide the details from the programmer.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2012-12-04 07:37
    David Betz wrote: »
    Seems like Dave's code for blinking an LED is mostly longer because his Forth interpreter offers more flexiblity in setting up execution on another COG. How does Tachyon decide what size stacks to use and where to place them?
    Tachyon's stacks are cog based so there is no need to allocate hub memory although there are the optional "hub registers" which can be switched but most tasks don't need their own set as these mostly have to do with the text interpreter. Now flexibility is fine as long as it is not necessary to setup all those parameters each time but only change the ones you want. Now however if you like complexity then I understand but I myself favor simplicity along with functionality.
  • David BetzDavid Betz Posts: 14,516
    edited 2012-12-04 07:52
    Tachyon's stacks are cog based so there is no need to allocate hub memory although there are the optional "hub registers" which can be switched but most tasks don't need their own set as these mostly have to do with the text interpreter. Now flexibility is fine as long as it is not necessary to setup all those parameters each time but only change the ones you want. Now however if you like complexity then I understand but I myself favor simplicity along with functionality.
    I didn't realize that Tachyon's stacks were in COG memory. I guess that means you need to use self-modifying code to implement the stack pointers. Is that really faster than just placing the stacks in hub memory? I guess on the P2 you can use the INDA/INDB registers or even the CLUT area for your stacks.
  • Dave HeinDave Hein Posts: 6,347
    edited 2012-12-04 08:56
    In Tachyon, the top of stack is always in a pre-defined hub location, so it doesn't need self-modifying code to access it. Operations that don't change the depth of the stack are very efficient using this technique. This would include unary operators and things such as SWAP and ROT.

    Operations that change the depth of the stack require all of the stack locations to be shuffled. An operation such as ADD will leave one less item on the stack, so all of the other stack locations must be copied toward the TOS. Operations such as DUP and OVER will leave one more item on the stack, and the rest of the stack items have to be copied to the next stack location.

    The version of Tachyon that I looked at uses 12 locations for the data stack, 18 for the return stack and 8 for a loop stack.

    As I said before, the toggle code is intended to demonstrate the functionality of starting a Forth cog. It allows for quite a bit of flexibility, and would be even more complex if the programmer wanted to pre-load the Forth cog stack with parameters and provide an exit routine that automatically stops the cog. I'll probably write a program that demonstrates that capability. I'll also provide a few more words that hard-code stack sizes to make it simpler to start a Forth cog.
  • David BetzDavid Betz Posts: 14,516
    edited 2012-12-04 09:02
    Dave Hein wrote: »
    In Tachyon, the top of stack is always in a pre-defined hub location, so it doesn't need self-modifying code to access it. Operations that don't change the depth of the stack are very efficient using this technique. This would include unary operators and things such as SWAP and ROT.

    Operations that change the depth of the stack require all of the stack locations have to be shuffled. An operation such as ADD will leave one less item on the stack, so all of the other stack locations must be copied toward the TOS. Operations such as DUP and OVER will leave one more item on the stack, and the rest of the stack items have to be copied to the next stack location.

    The version of Tachyon that I looked at uses 12 locations for the data stack, 18 for the return stack and 8 for a loop stack.

    As I said before, the toggle code is intended to demonstrate the functionality of starting a Forth cog. It allows for quite a bit of flexibility, and would be even more complex is the programmer wanted to pre-load the Forth cog stack with parameters and provide an exit routine that automatically stops the cog. I'll probably write program that demonstrates that capability. I'll also provide a few more words that hard-code stack sizes to make it simpler to start a Forth cog.

    Hmmm... I know nothing about Forth programming but I would think it would involve a lot of pushing and popping so shuffling the stack every time seems like it might be cumbersome. I guess if it's done at COG speeds it's pretty fast though.
Sign In or Register to comment.