1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

Embedded Basic Interpreter

Discussion in 'Embedded' started by Gary Pace, Apr 2, 2006.

  1. Gary Pace

    Gary Pace Guest

    Howdy Y'all :
    I am designing an embedded controller that needs an application programming
    ability.
    In the base layers of the software I have the basic control blocks running
    in compiled C, with setup, referencing and monitoring via registers accessed
    via MODBUS links.
    What I would like to do is :
    1 - Include a BASIC interpreter in my core code. This would be sourced in
    generic C and ported to my compiler
    2 - Extend the BASIC dialect to have non-standard keywords that I will map
    onto API functions in my base code (get and set functions to provide lvalues
    and accept assignments). I would somehow throw exceptions at the interpreter
    if it made illegal assignments to the control layer
    Now I don't want to write a BASIC interpreter myself, so does anybody know
    of an interpreter written in C that I can include in my source, point at its
    code-to-run (pre-compiled to a byte code offline ideally), point at its
    memory for stacks, heaps etc and provide its API's for assigning to/getting
    the value of "Controller Variable N"
    Thanks
    Gary
     
    Gary Pace, Apr 2, 2006
    #1
    1. Advertising

  2. Gary Pace

    Guest

    Gary Pace wrote:
    > Howdy Y'all :
    > I am designing an embedded controller that needs an application programming
    > ability.
    > In the base layers of the software I have the basic control blocks running
    > in compiled C, with setup, referencing and monitoring via registers accessed
    > via MODBUS links.
    > What I would like to do is :
    > 1 - Include a BASIC interpreter in my core code. This would be sourced in
    > generic C and ported to my compiler
    > 2 - Extend the BASIC dialect to have non-standard keywords that I will map
    > onto API functions in my base code (get and set functions to provide lvalues
    > and accept assignments). I would somehow throw exceptions at the interpreter
    > if it made illegal assignments to the control layer
    > Now I don't want to write a BASIC interpreter myself, so does anybody know
    > of an interpreter written in C that I can include in my source, point at its
    > code-to-run (pre-compiled to a byte code offline ideally), point at its
    > memory for stacks, heaps etc and provide its API's for assigning to/getting
    > the value of "Controller Variable N"




    While not Basic, Tcl may be a good fit. It's OSS and easily extensible.
     
    , Apr 2, 2006
    #2
    1. Advertising

  3. Gary Pace

    Leon Guest

    Gary Pace wrote:
    > Howdy Y'all :
    > I am designing an embedded controller that needs an application programming
    > ability.
    > In the base layers of the software I have the basic control blocks running
    > in compiled C, with setup, referencing and monitoring via registers accessed
    > via MODBUS links.
    > What I would like to do is :
    > 1 - Include a BASIC interpreter in my core code. This would be sourced in
    > generic C and ported to my compiler
    > 2 - Extend the BASIC dialect to have non-standard keywords that I will map
    > onto API functions in my base code (get and set functions to provide lvalues
    > and accept assignments). I would somehow throw exceptions at the interpreter
    > if it made illegal assignments to the control layer
    > Now I don't want to write a BASIC interpreter myself, so does anybody know
    > of an interpreter written in C that I can include in my source, point at its
    > code-to-run (pre-compiled to a byte code offline ideally), point at its
    > memory for stacks, heaps etc and provide its API's for assigning to/getting
    > the value of "Controller Variable N"
    > Thanks
    > Gary


    Rowley Associates have a BASIC interpreter for the ARM:

    http://www.rowley.co.uk

    Leon
     
    Leon, Apr 2, 2006
    #3
  4. Gary Pace

    Jim Stewart Guest

    Gary Pace wrote:
    > Howdy Y'all :
    > I am designing an embedded controller that needs an application programming
    > ability.
    > In the base layers of the software I have the basic control blocks running
    > in compiled C, with setup, referencing and monitoring via registers accessed
    > via MODBUS links.
    > What I would like to do is :
    > 1 - Include a BASIC interpreter in my core code. This would be sourced in
    > generic C and ported to my compiler
    > 2 - Extend the BASIC dialect to have non-standard keywords that I will map
    > onto API functions in my base code (get and set functions to provide lvalues
    > and accept assignments). I would somehow throw exceptions at the interpreter
    > if it made illegal assignments to the control layer
    > Now I don't want to write a BASIC interpreter myself, so does anybody know
    > of an interpreter written in C that I can include in my source, point at its
    > code-to-run (pre-compiled to a byte code offline ideally), point at its
    > memory for stacks, heaps etc and provide its API's for assigning to/getting
    > the value of "Controller Variable N"
    > Thanks
    > Gary


    David Dunfield had a little BASIC interpreter
    written in C. You might send him an email

    http://www.dunfield.com/downloads.htm
     
    Jim Stewart, Apr 2, 2006
    #4
  5. Gary Pace

    larwe Guest

    wrote:

    > > 1 - Include a BASIC interpreter in my core code. This would be sourced in

    >
    > While not Basic, Tcl may be a good fit. It's OSS and easily extensible.


    Number of BASIC programmers vs. number of Tcl programmers?

    Applicability of saccharine education-substitute (Visual BASIC) to Tcl
    vs. a BASIC dialect?
     
    larwe, Apr 2, 2006
    #5
  6. Gary Pace

    Dave Hansen Guest

    On Sun, 02 Apr 2006 05:29:40 GMT in comp.arch.embedded, "Gary Pace"
    <> wrote:

    >Howdy Y'all :
    >I am designing an embedded controller that needs an application programming
    >ability.

    [...]
    >Now I don't want to write a BASIC interpreter myself, so does anybody know
    >of an interpreter written in C that I can include in my source, point at its
    >code-to-run (pre-compiled to a byte code offline ideally), point at its
    >memory for stacks, heaps etc and provide its API's for assigning to/getting
    >the value of "Controller Variable N"


    I don't know about BASIC, but you might want to look at Lua. It's
    designed to be an embedded scripting language, and has a very easy to
    understand syntax and a favorable license. www.lua.org

    Regards,
    -=Dave

    --
    Change is inevitable, progress is not.
     
    Dave Hansen, Apr 2, 2006
    #6
  7. Gary Pace

    Guest

    Dave Hansen wrote:
    > On Sun, 02 Apr 2006 05:29:40 GMT in comp.arch.embedded, "Gary Pace"
    > <> wrote:
    >
    > >Howdy Y'all :
    > >I am designing an embedded controller that needs an application programming
    > >ability.

    > [...]
    > >Now I don't want to write a BASIC interpreter myself, so does anybody know
    > >of an interpreter written in C that I can include in my source, point at its
    > >code-to-run (pre-compiled to a byte code offline ideally), point at its
    > >memory for stacks, heaps etc and provide its API's for assigning to/getting
    > >the value of "Controller Variable N"

    >
    > I don't know about BASIC, but you might want to look at Lua. It's
    > designed to be an embedded scripting language, and has a very easy to
    > understand syntax and a favorable license. www.lua.org
    >
    > Regards,
    > -=Dave
    >
    > --
    > Change is inevitable, progress is not.


    There's always tiny basic (I'm a bit amazed that I can still remember
    buying the issue of Dr Dobbs it was published in).

    There was a recent article in Dr Dobbs (Jan 2006?) by the guy who wrote
    the original, he has his own web site at:
    http://www.ittybittycomputers.com/IttyBitty/TinyBasic/

    and here's another version written in C:
    http://www.ddj.com/documents/s=10032/q=1/ddj0601b/0601b.html

    It looks like less than 1000 lines of code. How hard could it be to get
    working :)

    Not sure what the copyright arrangements are for either of these, and I
    have never used either. But they look interesting.

    Post something back to the group if these ore something else you find
    works for you.

    Mark
     
    , Apr 2, 2006
    #7
  8. Gary Pace

    Leon Guest

    wrote:
    > Dave Hansen wrote:
    > > On Sun, 02 Apr 2006 05:29:40 GMT in comp.arch.embedded, "Gary Pace"
    > > <> wrote:
    > >
    > > >Howdy Y'all :
    > > >I am designing an embedded controller that needs an application programming
    > > >ability.

    > > [...]
    > > >Now I don't want to write a BASIC interpreter myself, so does anybody know
    > > >of an interpreter written in C that I can include in my source, point at its
    > > >code-to-run (pre-compiled to a byte code offline ideally), point at its
    > > >memory for stacks, heaps etc and provide its API's for assigning to/getting
    > > >the value of "Controller Variable N"

    > >
    > > I don't know about BASIC, but you might want to look at Lua. It's
    > > designed to be an embedded scripting language, and has a very easy to
    > > understand syntax and a favorable license. www.lua.org
    > >

    L > Regards,
    > > -=Dave
    > >
    > > --
    > > Change is inevitable, progress is not.

    >
    > There's always tiny basic (I'm a bit amazed that I can still remember
    > buying the issue of Dr Dobbs it was published in).
    >
    > There was a recent article in Dr Dobbs (Jan 2006?) by the guy who wrote
    > the original, he has his own web site at:
    > http://www.ittybittycomputers.com/IttyBitty/TinyBasic/
    >
    > and here's another version written in C:
    > http://www.ddj.com/documents/s=10032/q=1/ddj0601b/0601b.html
    >
    > It looks like less than 1000 lines of code. How hard could it be to get
    > working :)
    >
    > Not sure what the copyright arrangements are for either of these, and I
    > have never used either. But they look interesting.
    >
    > Post something back to the group if these ore something else you find
    > works for you.
    >
    > Mark


    I just downloaded the C version and compiled it with gcc. It works OK.

    I remember that issue of DDJ, as well. A friend of mine keyed Wang's
    Tiny BASIC into his S100 system (in hex) and got it working. It was
    later used on the original 4k TRS-80 Level 1 Model I. The 16k Level 2
    version used Microsoft BASIC.

    Leon
     
    Leon, Apr 3, 2006
    #8
  9. Gary Pace

    Jim Stewart Guest

    Leon wrote:
    > wrote:
    >
    >>Dave Hansen wrote:
    >>
    >>>On Sun, 02 Apr 2006 05:29:40 GMT in comp.arch.embedded, "Gary Pace"
    >>><> wrote:
    >>>
    >>>
    >>>>Howdy Y'all :
    >>>>I am designing an embedded controller that needs an application programming
    >>>>ability.
    >>>
    >>>[...]
    >>>
    >>>>Now I don't want to write a BASIC interpreter myself, so does anybody know
    >>>>of an interpreter written in C that I can include in my source, point at its
    >>>>code-to-run (pre-compiled to a byte code offline ideally), point at its
    >>>>memory for stacks, heaps etc and provide its API's for assigning to/getting
    >>>>the value of "Controller Variable N"
    >>>
    >>>I don't know about BASIC, but you might want to look at Lua. It's
    >>>designed to be an embedded scripting language, and has a very easy to
    >>>understand syntax and a favorable license. www.lua.org
    >>>

    >
    > L > Regards,
    >
    >>> -=Dave
    >>>
    >>>--
    >>>Change is inevitable, progress is not.

    >>
    >>There's always tiny basic (I'm a bit amazed that I can still remember
    >>buying the issue of Dr Dobbs it was published in).
    >>
    >>There was a recent article in Dr Dobbs (Jan 2006?) by the guy who wrote
    >>the original, he has his own web site at:
    >>http://www.ittybittycomputers.com/IttyBitty/TinyBasic/
    >>
    >>and here's another version written in C:
    >>http://www.ddj.com/documents/s=10032/q=1/ddj0601b/0601b.html
    >>
    >>It looks like less than 1000 lines of code. How hard could it be to get
    >>working :)
    >>
    >>Not sure what the copyright arrangements are for either of these, and I
    >>have never used either. But they look interesting.
    >>
    >>Post something back to the group if these ore something else you find
    >>works for you.
    >>
    >>Mark

    >
    >
    > I just downloaded the C version and compiled it with gcc. It works OK.
    >
    > I remember that issue of DDJ, as well. A friend of mine keyed Wang's
    > Tiny BASIC into his S100 system (in hex) and got it working. It was
    > later used on the original 4k TRS-80 Level 1 Model I. The 16k Level 2
    > version used Microsoft BASIC.


    I can go you one better. I wrote and
    integrated save and load functions into
    it for a Phi-deck digital cassette deck.
     
    Jim Stewart, Apr 3, 2006
    #9
  10. Gary Pace

    msg Guest

    Jim Stewart wrote:

    > I can go you one better. I wrote and
    > integrated save and load functions into
    > it for a Phi-deck digital cassette deck.
    >


    I bought the Phi-deck dual drive eval kit at Wescon
    when it came out (still packed away until I can
    get at it). Do you have your code and interface
    schematic?

    Regards,

    Michael Grigoni
    Cybertheque Museum
     
    msg, Apr 3, 2006
    #10
  11. Gary Pace

    Jim Stewart Guest

    msg wrote:

    > Jim Stewart wrote:
    >
    >> I can go you one better. I wrote and
    >> integrated save and load functions into
    >> it for a Phi-deck digital cassette deck.
    >>

    >
    > I bought the Phi-deck dual drive eval kit at Wescon
    > when it came out (still packed away until I can
    > get at it). Do you have your code and interface
    > schematic?


    Long gone, sadly. I was one of 3 working
    at a tiny startup in Oakland Cal. We were
    all IMSAI vets. One guy did the analog,
    another did the digital interface and a
    third that wasn't present did the OS. It
    ran a very early spinoff of CP/M with a
    block oriented structure like Dectape.

    It worked pretty good, but we couldn't
    compete with Northstar's cheap floppy.
     
    Jim Stewart, Apr 3, 2006
    #11
  12. Gary Pace

    msg Guest

    Leon wrote:

    > I just downloaded the C version and compiled it with gcc. It works OK.


    I compiled it with __STDC__ on AT&T SVR4 and it works well.

    Regards,

    Michael Grigoni
    Cybertheque Museum
     
    msg, Apr 3, 2006
    #12
  13. Gary Pace

    Guest

    larwe wrote:
    > wrote:
    >
    > > > 1 - Include a BASIC interpreter in my core code. This would be sourced in

    > >
    > > While not Basic, Tcl may be a good fit. It's OSS and easily extensible.

    >
    > Number of BASIC programmers vs. number of Tcl programmers?
    >
    > Applicability of saccharine education-substitute (Visual BASIC) to Tcl
    > vs. a BASIC dialect?



    Don't know, but VB certainly won't teach anyone anything very useful
    related to what you're likely to find in an embedded Basic scripting
    language.
     
    , Apr 3, 2006
    #13
  14. "Dave Hansen" <> wrote in message
    news:...
    > On Sun, 02 Apr 2006 05:29:40 GMT in comp.arch.embedded, "Gary Pace"
    > <> wrote:
    >
    > >Howdy Y'all :
    > >I am designing an embedded controller that needs an application

    programming
    > >ability.

    > [...]
    > >Now I don't want to write a BASIC interpreter myself, so does anybody

    know
    > >of an interpreter written in C that I can include in my source, point at

    its
    > >code-to-run (pre-compiled to a byte code offline ideally), point at its
    > >memory for stacks, heaps etc and provide its API's for assigning

    to/getting
    > >the value of "Controller Variable N"

    >
    > I don't know about BASIC, but you might want to look at Lua. It's
    > designed to be an embedded scripting language, and has a very easy to
    > understand syntax and a favorable license. www.lua.org


    I too am looking for a scripting option. I had a look at Lua. No problems
    porting it to my system, except one of my own making. The code added about
    100K, which is OK for me, but RAM is tight and Lua used about 25K of RAM
    just to start up (priune the libs could reduce that) - that was just too
    much in my case.

    Peter
     
    Peter Dickerson, Apr 3, 2006
    #14
  15. Gary Pace

    KenLem Guest

    I'm in the middle of writing a Basic byte code compiler for the Cypress
    PSoC's. The VM is currently in C but I will port it to ASM once I have
    it feature complete.

    It's an interesting task.
     
    KenLem, Apr 5, 2006
    #15
  16. Gary Pace

    Norm Dresner Guest

    "KenLem" <> wrote in message
    news:...
    | I'm in the middle of writing a Basic byte code compiler for the Cypress
    | PSoC's. The VM is currently in C but I will port it to ASM once I have
    | it feature complete.
    |
    | It's an interesting task.

    If you leave it in C, it will be easier to port to other CPUs. And could
    become a viable product in its own right.

    Norm
     
    Norm Dresner, Apr 6, 2006
    #16
  17. Gary Pace

    KenLem Guest

    I hope to always maintain the master version of the VM in C for just
    those reasons. I need to port it to ASM for the PSoC because it takes
    up around 5k in C but I suspect it would be < 2k in ASM. I'm working
    with the the PRoC which has a built in radio and I don't have much room
    left over for the VM.

    Also, the select statement in the C compiler I'm using generates a
    giant if then else when it parses the bytecodes. I'm using a jump
    table in ASM that should really speed up the VM. Of course, my main
    concern with the VM isn't speed. I just a little multi-purpose device
    with a radio on it.

    > If you leave it in C, it will be easier to port to other CPUs. And could
    > become a viable product in its own right.
    >
    > Norm
     
    KenLem, Apr 6, 2006
    #17
  18. KenLem <> wrote:

    > Also, the select statement in the C compiler I'm using generates a
    > giant if then else when it parses the bytecodes.


    <nitpick>No, it doesn't: C has no select statement</nitpick>.

    And you cannot use a better C compiler?

    > I'm using a jump table in ASM that should really speed up the VM.


    If you think you need ASM just to implement a jump table in C, then
    maybe you need to re-think your plan, and learn how to utilize the
    language you have well before you venture into making your own one.
    Jump tables are trivially implementable as arrays of functions
    pointers, in C.

    --
    Hans-Bernhard Broeker (-aachen.de)
    Even if all the snow were burnt, ashes would remain.
     
    Hans-Bernhard Broeker, Apr 6, 2006
    #18
  19. Gary Pace

    KenLem Guest

    Hans,

    OK, no select but switch statement. I apologize for my error.

    I know I can implement a jump table in C but thanks for your reply.
    The switch to ASM has more to do with code space than speed.

    As far as I know, there is only one C compiler for the PSoC. I'm not
    complaining about its code generation size. It's pretty good however
    it is still a C compiler. The target device has 8k flash and the VM
    is now around 5k. I need the VM to fit in around 2k to allow room for
    other function such as the radio. I could code the jump table in C but
    I don' t think I'll see the type of size reduction I can expect by
    writing the entire VM by hand in ASM. It might be worth the effort to
    find out just what the size reduction would be.
     
    KenLem, Apr 6, 2006
    #19
  20. On 6 Apr 2006 20:14:10 GMT, Hans-Bernhard Broeker
    <-aachen.de> wrote:

    >KenLem <> wrote:
    >
    >> Also, the select statement in the C compiler I'm using generates a
    >> giant if then else when it parses the bytecodes.

    >
    ><nitpick>No, it doesn't: C has no select statement</nitpick>.
    >
    >And you cannot use a better C compiler?
    >
    >> I'm using a jump table in ASM that should really speed up the VM.

    >
    >If you think you need ASM just to implement a jump table in C, then
    >maybe you need to re-think your plan, and learn how to utilize the
    >language you have well before you venture into making your own one.
    >Jump tables are trivially implementable as arrays of functions
    >pointers, in C.


    Strictly speaking it would be a call table. GCC supports a computed
    goto, where one can have an array of goto labels. This generates a
    true jump table. I am not aware of other C compilers that
    support this extention.

    Regards
    Anton Erasmus
     
    Anton Erasmus, Apr 7, 2006
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    451
    Jon Kirwan
    Mar 9, 2009
  2. Jon Kirwan
    Replies:
    49
    Views:
    951
  3. Anton Erasmus
    Replies:
    2
    Views:
    341
    Jon Kirwan
    Mar 10, 2009
  4. M.O.B. i L.
    Replies:
    1
    Views:
    576
    Jon Kirwan
    Mar 9, 2009
  5. -jg
    Replies:
    0
    Views:
    355
Loading...

Share This Page