Shop OBEX P1 Docs P2 Docs Learn Events
Femtobasic compiler? — Parallax Forums

Femtobasic compiler?

RaymanRayman Posts: 14,827
edited 2009-05-15 20:12 in Propeller 1
Shouldn't it be possible to compile Femtobasic into some kind of bytecode to make it faster?· Did anybody already look at this?· Seems like it could be possible to do this in SPIN even...

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm

Comments

  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2009-05-15 00:49
    P
    L
    E This sounds like a great project!
    A A Femtobasic compiler would be very cool indeed!
    S
    E (I wonder if Mike Green ever thought it would be taken as far as it has. [noparse]:)[/noparse]

    D
    OBC

    T
    H
    I
    S

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New to the Propeller?

    Visit the: The Propeller Pages @ Warranty Void.
  • trodosstrodoss Posts: 577
    edited 2009-05-15 03:24
    @Rayman,

    Ever since I saw the Catalina project, I have been thinking along the similar lines.·

    Compiling·source to a sort of p-code and writing an p-code interpreter/kernel should be possible.·

    The project that I found·that was similar was the JVM for the prop:

    http://forums.parallax.com/showthread.php?p=703261

    Certianly if it is something you are planning on tackling I will be more than happy to provide any help I can.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-05-15 03:47
    I had started on something like that, got far enough so that it would allocate storage and compile LMM code for simple expressions including an IF statement and GOTO statement and program labels, then ran out of room. I haven't gotten back to it since it really needed some foundational work like multi-file read/write to some kind of mass storage. I'm nearly done with a flash memory file system for Winbond SPI flash memories and that may be enough for what I need.

    Here are a couple of threads with the files:

    http://forums.parallax.com/showthread.php?p=714097

    http://forums.parallax.com/showthread.php?p=755835
  • trodosstrodoss Posts: 577
    edited 2009-05-15 11:44
    @Mike,
    Thanks! I had forgotten that you had worked on that before. I will definately take a look again at the code.
  • RaymanRayman Posts: 14,827
    edited 2009-05-15 12:39
    I think Harrision has modified the SD code for multiple files. Maybe we can lean on him to give it MIT license? Otherwise, I'm pretty sure I can do that myself, if that's the main problem.

    Mike: Thanks for the links. I'll look at what you've done...

    I think there are some people who would be interested in just coding and compiling BASIC in Windows and then downloading to the Prop...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • BradCBradC Posts: 2,601
    edited 2009-05-15 12:58
    Rayman said...

    I think there are some people who would be interested in just coding and compiling BASIC in Windows and then downloading to the Prop...

    It would not be difficult to write a PC based BASIC compiler that targeted SPIN bytecode.. I've played with it myself a little bit, but I still believe SPIN is a far better fit for the interpreter. If people won't take the effort to learn an alternative language then the BASIC stamp forum is just a click away.

    If all you have is a hammer..

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "VOOM"?!? Mate, this bird wouldn't "voom" if you put four million volts through it! 'E's bleedin' demised!
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2009-05-15 13:14
    If I'm going to program on the PC, then spin would be my choice as well.
    If we're talking about programming in something that could be
    both programmed and compiled on the Propeller, then BASIC is the
    logicial choice as a starting point, as spin will require having multiple source
    files opened during compile even if you were editing them one at a time.

    I might feel differently if I had extensive STAMP background, but
    if we program in BASIC on a PC for a Propeller, then you've pretty
    much duplicated the STAMP.

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New to the Propeller?

    Visit the: The Propeller Pages @ Warranty Void.
  • RaymanRayman Posts: 14,827
    edited 2009-05-15 13:32
    These are good points. However, I'm thinking about use with my "Propeller System Module", for which Femtobasic would have several additional features, such as drawing lines and circles, etc. (Much like the FemtoBasic for the Oled96Prop device). Also the pins for certain devices (such as SD and audio) are fixed. So anyway, I think I can make a BASIC for Windows that would be so easy that a child could do it (literally).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2009-05-15 13:52
    Sounds like a simple entry point for working with the Propeller.
    Go for it. I'd love to get my nine year old daughter playing with
    something like this. She loves the Hydra Logo program.

    Anything that provides that "instant feedback" can't go wrong.

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New to the Propeller?

    Visit the: The Propeller Pages @ Warranty Void.
  • trodosstrodoss Posts: 577
    edited 2009-05-15 14:26

    It would not be difficult to write a PC based BASIC compiler that targeted SPIN bytecode.. I've played with it myself a little bit, but I still believe SPIN is a far better fit for the interpreter. If people won't take the effort to learn an alternative language then the BASIC stamp forum is just a click away.

    If all you have is a hammer..

    I agree that compiling to Spin bytecode on the PC would be possible, if someone put in the effort.· Spin is going to be the 'best' fit for the Spin interpreter (as·OBC/BradC mentioned).

    I think the direction I was going to go·is·similar to what Mike Green has been working on.· It would be nice to have programs edited, complied, and run on the Propeller.· Sounds like, with XMM, that a Catalina compiler running on a Propeller platform is possible.· Certianly gives hope that a BASIC compiler could be made as well.
    Rayman said...
    I think I can make a BASIC for Windows that would be so easy that a child could do it (literally).
    MSFT has been working on SmallBasic (http://msdn.microsoft.com/en-us/devlabs/cc950524.aspx)· It is a pretty simple BASIC·with a little·nod to LOGO thrown in for good measure (for all those "turtle" fans out there).· It sounds like that is what you want to achieve for the Propeller.· Might be something you could at least look at and maybe 'borrow' some features from.





    Post Edited (trodoss) : 5/15/2009 2:31:34 PM GMT
  • SciNemoSciNemo Posts: 91
    edited 2009-05-15 20:02
    I am just throwing this out here because I am curious, but what is stopping someone from making a version of basic, (or rather a native PASM assembler) that just reads through op codes that the user enters one at a time and loads them into memory? The PASM assembler would act like Femto Basic, but sit in it's own chunk of RAM separate from the user program. Some kind of break routine would have to be worked out so you could exit back to editing mode, but even if that routine was called every other instruction it would still be faster than spin or the current femto basic (I am just guessing, please correct me if i'm wrong).

    I know there is a project going on that aims to do something similar to this, but what is the big difficulty? If it could be done it would mean you could get instant feedback, high speed, and the ability to develop programs for the prop right on the prop.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Not the fish.
    sites.google.com/site/bitwinproject/
  • Mike GreenMike Green Posts: 23,101
    edited 2009-05-15 20:12
    There are several versions of Forth for the Propeller that allow you to do just that. Forth includes an assembler and it allows you to enter programs, but they have to be entered in Forth.

    FemtoBasic is native for the Propeller, but it's a slow interpreter. You can already get instant feedback and the ability to develop programs for the Propeller right on the Propeller. You can even access some of the high speed functions like the cog counters.
Sign In or Register to comment.