Shop OBEX P1 Docs P2 Docs Learn Events
Urban M — Parallax Forums

Urban M

jazzedjazzed Posts: 11,803
edited 2009-10-30 04:00 in Propeller 1
Thought I would spend some time making the BF language work on Propeller. Here's the result so far.

BF is a programmer's toy; it is an incredibly obscure "write only language" (this means "once you write it, you may as well forget about reading and understanding it after just a few hours" [noparse]:)[/noparse] The BF interpreter is implemented in less than 120 PASM instructions (I've not tried to optimize it).

The interpreter works with lots of code but there are challenges that I haven't debugged yet ... this is a work in progress ... and may forever be a WIP depending on how I feel [noparse]:)[/noparse]. UPDATE: Found that primes.bf is looking for 10 as ENTER ... changed to 13 and now works with PST (warm fuzzy feeling).

Various trivial demo program strings such as "Hello World!" are included. The "99 Bottles" demo is default.

The PASM interpreter has an interface to serial input/output provided by the demo code; the interface should be easily changed to a keyboard/TV with a little work. The _XINFREQ is set to 6MHz (PLL16), so watch out.

Cheers.
--Steve

Post Edited (jazzed) : 10/30/2009 1:45:18 AM GMT

Comments

  • heaterheater Posts: 3,370
    edited 2009-10-29 21:47
    So how is your brain after that?

    That must be about the smallest interpreter around.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-10-29 21:57
    I'm not so sure that BF, or something similar, is totally bereft of practicality. It may well be an appropriate language for adaptive programming via a genetic algorithm. It has a small alphabet and is much more DNA-like than typical procedural languages. Moreover, once a program is optimized, there is no reason it couldn't be translated back into something that runs more quickly.

    -Phil
  • jazzedjazzed Posts: 11,803
    edited 2009-10-29 22:20
    heater said...
    So how is your brain after that?
    Feeling very mushy at this point!

    The BF page on Wikipedia is pretty interesting. Just google "brainf***" with the stars or otherwise.
    There is a small repository of code on the net. For some reason I can't get primes.bf to work.
    There is a BF compiler written in BF [noparse]:)[/noparse] No idea what that does at this point.

    Playing with BF certainly makes one appreciate other languages. Not even an "=" sign ... jeez.
    Seems like the patterns that end up being used in the source are more like spells than anything.

    Post Edited (jazzed) : 10/30/2009 1:55:53 AM GMT
  • jazzedjazzed Posts: 11,803
    edited 2009-10-30 00:39
    Turns out the misery with primes.bf was caused by PST sending 13 instead of 10 for ENTER (or primes.bf expecting 10 instead of 13). The attached prime.bf code works expecting 13 for ENTER ... doesn't seem to find enough numbers though. Maybe I'm just impatient. The original bf code I posted works with this and PST. Look here for more BF sources (some may need adjustments ... good luck with that ! s).

    Brainf***
    Primes up to: 200
    2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113
    
    


    --Steve

    Post Edited (jazzed) : 10/30/2009 1:40:11 AM GMT
  • Ron SutcliffeRon Sutcliffe Posts: 420
    edited 2009-10-30 00:57
    Jazzed

    : Five_stars 5 0 do 2a emit loop 0d emit ;

    cheers
  • jazzedjazzed Posts: 11,803
    edited 2009-10-30 01:48
    Thanks Ron. I actually understand what that does [noparse]:)[/noparse] Is it finished ?
  • CounterRotatingPropsCounterRotatingProps Posts: 1,132
    edited 2009-10-30 01:50
    > Feeling very mushy at this point!

    Steve, we all were worried about your Brain *before* you did this ...

    please pull your self back from the brink and go code some sensible PASM stuff, OK?

    tongue.gif·tongue.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • Ron SutcliffeRon Sutcliffe Posts: 420
    edited 2009-10-30 04:00
    The short answer is no, but getting close.

    Long answer.
    The hub version of the Dictionary stuff, add_word, find_word, TIB parser, etc are ok now. Some core primatives have been done. Now I am moving the dictionary out of HUB into Xmem. I need to find out how fast I can access a dictionary word from the Xmem. I am only concerned about reads. I want minimal Forth to run in a single cog, leaving most of the Hub free. Forth, hopefully can run along other spin cogs. I have yet to see if I have set the bar too high, but the journey is fascinating.

    Ron
Sign In or Register to comment.