Shop OBEX P1 Docs P2 Docs Learn Events
ebasic documentation? — Parallax Forums

ebasic documentation?

RaymanRayman Posts: 14,665
edited 2013-04-26 16:40 in Propeller 1
The ebasic demo is kinda interesting. jazzed suggested using it as a performance benchmark.
So, I started looking closer at it...

There are some notes in the README.txt file. The code appears to be from David Betz with "all rights reserved".

David, did you write this from scratch?
Is there no GNU version of BASIC out there for GCC?

Does it really compile before running? Can you save the compiled version?
«1

Comments

  • David BetzDavid Betz Posts: 14,516
    edited 2013-04-22 09:47
    Rayman wrote: »
    The ebasic demo is kinda interesting. jazzed suggested using it as a performance benchmark.
    So, I started looking closer at it...

    There are some notes in the README.txt file. The code appears to be from David Betz with "all rights reserved".

    David, did you write this from scratch?
    Is there no GNU version of BASIC out there for GCC?

    Does it really compile before running? Can you save the compiled version?
    I'm afraid the README is the only documentation at present. I'm not sure how practical ebasic is although I have a faster bytecode interpreter that I wrote for my xbasic system that I'd like to merge with ebasic. That should make ebasic programs nearly as fast as Spin programs.

    Yes, I wrote ebasic. I'm not sure I can say I wrote it from scratch because every language I've written for the past 30 years has been based on bits and pieces of other earlier languages that I wrote. This one borrows from a text adventure authoring system I wrote ages ago called AdvSys.

    There may be a GNU Basic out there somewhere. I'd be surprised if there isn't. It will almost certainy be far bigger though.
  • David BetzDavid Betz Posts: 14,516
    edited 2013-04-22 09:52
    Rayman wrote: »
    The code appears to be from David Betz with "all rights reserved"
    It is available under the MIT license. I should update the source files to say that.
  • RaymanRayman Posts: 14,665
    edited 2013-04-22 10:12
    Could it be easily made to save and run compiled versions of BASIC programs?
  • David BetzDavid Betz Posts: 14,516
    edited 2013-04-22 10:17
    Rayman wrote: »
    Could it be easily made to save and run compiled versions of BASIC programs?
    xbasic can already do that but, as I said earlier, I need to port the xbasic VM to ebasic so it can run natively on the Propeller. I intend to do that but I'm not sure when I'll have time.
  • RaymanRayman Posts: 14,665
    edited 2013-04-23 04:04
    David, I did notice one thing that might be easy to fix...
    When running in xmm modes in SimpleIDE, the terminal window misses the first welcome prompt...
    Only see it in SD or other slow modes...
  • David BetzDavid Betz Posts: 14,516
    edited 2013-04-23 04:50
    Rayman wrote: »
    David, I did notice one thing that might be easy to fix...
    When running in xmm modes in SimpleIDE, the terminal window misses the first welcome prompt...
    Only see it in SD or other slow modes...
    I think that's because it takes a while for the SimpleIDE terminal window to start up. The only real way to fix that is to add a sleep call to ebasic and I'm not sure I really want to do that since it isn't a problem if ebasic boots from EEPROM or if you load it using propeller-load directly. At some point we'll have to figure out how to avoid having SimpleIDE drop the initial output from programs.
  • jazzedjazzed Posts: 11,803
    edited 2013-04-23 07:36
    David Betz wrote: »
    At some point we'll have to figure out how to avoid having SimpleIDE drop the initial output from programs.

    Sorry, that will not happen.
  • jazzedjazzed Posts: 11,803
    edited 2013-04-23 10:35
    If you want to add a startup delay to any program, you can add a file like init.c below to the project.
    The constructor is always called before main. It's a good place to turn off buffering and other customizations.
    [FONT=courier new]/** @file init.c */
    #include <propeller.h>
    __attribute__((constructor)) void init(void)
    {
      /* assert tx pin low for QuickStart */
      OUTA &= ~(1<<30);
      DIRA |= (1<<30);
      /* wait a second for terminal to start */
      waitcnt(CLKFREQ+CNT);
    }[/FONT]
    
  • David BetzDavid Betz Posts: 14,516
    edited 2013-04-23 10:48
    jazzed wrote: »
    If you want to add a startup delay to any program, you can add a file like init.c below to the project.
    The constructor is always called before main. It's a good place to turn off buffering and other customizations.
    [FONT=courier new]/** @file init.c */
    #include <propeller.h>
    __attribute__((constructor)) void init(void)
    {
      /* assert tx pin low for QuickStart */
      OUTA &= ~(1<<30);
      DIRA |= (1<<30);
      /* wait a second for terminal to start */
      waitcnt(CLKFREQ+CNT);
    }[/FONT]
    
    Thanks Steve! That's very helpful and non-intrusive. But wasn't this called _InitIO or something like that? It's surprising that we would usurp a common function name like "init" for this sort of thing.
  • jazzedjazzed Posts: 11,803
    edited 2013-04-23 11:03
    David Betz wrote: »
    Thanks Steve! That's very helpful and non-intrusive. But wasn't this called _InitIO or something like that? It's surprising that we would usurp a common function name like "init" for this sort of thing.

    You can call it peanutbutterAndJellySandwitch() if you like.
  • David BetzDavid Betz Posts: 14,516
    edited 2013-04-23 11:07
    jazzed wrote: »
    You can call it peanutbutterAndJellySandwitch() if you like.
    Great! That sounds like a good suggestion. :-)
  • RaymanRayman Posts: 14,665
    edited 2013-04-23 17:57
    Maybe it 's late, but I just started to port fibo to ebasic and suddenly realized that basic is not so much fun anymore :(

    It's still a very nice demo though. Also, might be a basis for implementing a LOGO interpreter in GCC...
  • David BetzDavid Betz Posts: 14,516
    edited 2013-04-23 19:05
    Rayman wrote: »
    Maybe it 's late, but I just started to port fibo to ebasic and suddenly realized that basic is not so much fun anymore :(

    It's still a very nice demo though. Also, might be a basis for implementing a LOGO interpreter in GCC...
    Yeah, Basic, at least ebasic anyway, is not that great a language for serious work. I can expand it some but it really isn't a good base to build on. I have another language that I wrote a long time ago called Bob that is a bit like JavaScript. The nice thing is that it is interactive. You can type expressions at a prompt and get an immediate reply without having to go through some sort of "run" command like is required with ebasic. An immediate mode like that can make debugging programs a lot easier. You can test individual functions directly rather than having to write a test harness. I guess the Forth people understand that! The problem is, there are way too many languages out there already and I suspect a new one wouldn't get much use.
  • David BetzDavid Betz Posts: 14,516
    edited 2013-04-23 20:21
    Rayman wrote: »
    Maybe it 's late, but I just started to port fibo to ebasic and suddenly realized that basic is not so much fun anymore :(

    It's still a very nice demo though. Also, might be a basis for implementing a LOGO interpreter in GCC...
    Actually, porting fibo shouldn't be *that* hard. ebasic supports recursive functions.
  • RaymanRayman Posts: 14,665
    edited 2013-04-24 03:34
    That was where I got stuck... Wondering if and how it could do recursive functions...

    But, don't all variables have global scope?
  • David BetzDavid Betz Posts: 14,516
    edited 2013-04-24 04:45
    Rayman wrote: »
    That was where I got stuck... Wondering if and how it could do recursive functions...

    But, don't all variables have global scope?

    Try this:
    100 def fibo(n)
    110  if n<2 then
    120   return n
    130  else
    140   return fibo(n-1) + fibo(n-2)
    150  end if
    160 end def
    170 for i = 1 to 26
    180  print fibo(i)
    190 next i
    
  • RaymanRayman Posts: 14,665
    edited 2013-04-24 05:59
    Ok, thanks. Didn't know there was a "return x", that makes it easier...
  • David BetzDavid Betz Posts: 14,516
    edited 2013-04-24 06:32
    Rayman wrote: »
    Ok, thanks. Didn't know there was a "return x", that makes it easier...
    And, to answer your earlier question, no all variables do not have global scope. :-)
  • jazzedjazzed Posts: 11,803
    edited 2013-04-24 07:03
    Rayman wrote: »
    Ok, thanks. Didn't know there was a "return x", that makes it easier...

    It's in the readme. The readme isn't very easy on the eyes though. Someone should take time to make an html guide.

    The readme is missing info about the line number editor. The line numbers for example are not "goto" or "gosub" line numbers. There is a "label: goto label" convention, and "gosub" is replaced by functions.

    Also DIM is optional and variables can be more than one letter. It's not clear what the limits are and whether symbols can contain numbers and under-bars.
  • David BetzDavid Betz Posts: 14,516
    edited 2013-04-24 07:14
    jazzed wrote: »
    It's in the readme. The readme isn't very easy on the eyes though. Someone should take time to make an html guide.

    The readme is missing info about the line number editor. The line numbers for example are not "goto" or "gosub" line numbers. There is a "label: goto label" convention, and "gosub" is replaced by functions.

    Also DIM is optional and variables can be more than one letter. It's not clear what the limits are and whether symbols can contain numbers and under-bars.
    Right. The ebasic compiler doesn't see the line numbers. They are only used by the editor. I should write better documentation for ebasic I guess. I never thought anyone would actually try to use it! :-)
  • jazzedjazzed Posts: 11,803
    edited 2013-04-24 09:00
    Rayman,

    I'm trying to convince David that a version of ebasic (and/or xbasic) that could be split into smaller pieces might be useful. It could be split into an editor, compiler, and interpreter. All of it could be run from a monitor like Dave Hein's spinix (or some other loader). The xbasic version is very powerful in that among other things it can launch PASM cogs. Xbasic programs are also very small (maybe smaller than spin).

    Do you think that has any value?
  • David BetzDavid Betz Posts: 14,516
    edited 2013-04-24 09:07
    jazzed wrote: »
    Rayman,

    I'm trying to convince David that a version of ebasic (and/or xbasic) that could be split into smaller pieces might be useful. It could be split into an editor, compiler, and interpreter. All of it could be run from a monitor like Dave Hein's spinix (or some other loader). The xbasic version is very powerful in that among other things it can launch PASM cogs. Xbasic programs are also very small (maybe smaller than spin).

    Do you think that has any value?
    I don't think it has much value. In spite of what people claim, I don't really think anyone wants to do serious development on the Propeller. What was the name of that version of Spin that ran on the Propeller? Does anyone use that? If Propeller people aren't willing to use a Spin that compiles on the Propeller I doubt they will use any other language either (except maybe Forth).
  • RaymanRayman Posts: 14,665
    edited 2013-04-24 11:51
    I think it's an interesting demo. I used to program in qbasic and then VB. I think Parallax was built on a BASIC interpreter, so they might appreciate it...
    It may find a niche audience.

    I'm mostly interested in it because it's big and needs xmm modes to run...

    I don't think I'd actually build an application with it...
  • David BetzDavid Betz Posts: 14,516
    edited 2013-04-24 12:28
    Rayman wrote: »
    I think it's an interesting demo. I used to program in qbasic and then VB. I think Parallax was built on a BASIC interpreter, so they might appreciate it...
    It may find a niche audience.

    I'm mostly interested in it because it's big and needs xmm modes to run...

    I don't think I'd actually build an application with it...
    We already have FemtoBasic and PropBasic and the one Bean wrote to run directly on the Propeller, can't remember its name. I suppose that's probably enough.
  • RaymanRayman Posts: 14,665
    edited 2013-04-26 13:27
    Is there a way to stop a running program?
  • RaymanRayman Posts: 14,665
    edited 2013-04-26 13:46
    Just tried some benchmarking with that fibo code...

    Rampage2 with the x driver is ~4X faster than C3 in xmmc and split modes.
    So, I feel better about that now :)

    BTW: ebasic doesn't work with C3 in xmm-single mode... Is that a bug?
  • David BetzDavid Betz Posts: 14,516
    edited 2013-04-26 16:17
    Rayman wrote: »
    Is there a way to stop a running program?
    Sorry, not at present.
  • David BetzDavid Betz Posts: 14,516
    edited 2013-04-26 16:17
    Rayman wrote: »
    Just tried some benchmarking with that fibo code...

    Rampage2 with the x driver is ~4X faster than C3 in xmmc and split modes.
    So, I feel better about that now :)

    BTW: ebasic doesn't work with C3 in xmm-single mode... Is that a bug?
    It's probably too big. Both the code and data would have to fit in 64k.
  • RaymanRayman Posts: 14,665
    edited 2013-04-26 16:37
    Ok, that makes sense then, I didn't check. Didn't know it was that small...
  • David BetzDavid Betz Posts: 14,516
    edited 2013-04-26 16:40
    Rayman wrote: »
    Ok, that makes sense then, I didn't check. Didn't know it was that small...
    The C3 has two 32k byte SRAM chips for a total of 64k of SRAM. Any xmm-single program would have to fit in that space.
Sign In or Register to comment.