EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Embedded Basic interpreter recommendations?

Started by John Speth March 9, 2009
Hi everybody-

This question comes up from time to time from various posters but it never 
gets an answer that fits my specific needs.  Here goes:

Would anyone be able to recommend a free embedded basic interpreter with C 
source code?

My intended target is the STM32 which probably has enough RAM for small 
programs.  My intent is to create an embedded controller board with a serial 
port that will expose a Basic interpreter/monitor to a terminal emulator. 
The user will be able to interactively enter numbered program lines, 
save/load the program to/from flash, execute the program, and run Basic 
commands in immediate mode (non-numbered lines).  It's meant to be a tool 
for interactive experimentation of embedded concepts by non-programmer 
types.  I suppose it's much like a Basic Stamp.

I know "free" and all those features above is a tall order but if I can find 
an extensible package with some of those features it would be good too.

Thanks, JJS


On Mar 9, 2:04=A0pm, "John Speth" <johnsp...@yahoo.com> wrote:

> Would anyone be able to recommend a free embedded basic interpreter with =
C
> source code?
You investigated every option here? I see three at least that would probably fit your needs: <http://www.thefreecountry.com/compilers/ basic.shtml>
On Mon, 9 Mar 2009 11:04:03 -0700, "John Speth" <johnspeth@yahoo.com>
wrote:

>Hi everybody- > >This question comes up from time to time from various posters but it never >gets an answer that fits my specific needs. Here goes: > >Would anyone be able to recommend a free embedded basic interpreter with C >source code? > >My intended target is the STM32 which probably has enough RAM for small >programs. My intent is to create an embedded controller board with a serial >port that will expose a Basic interpreter/monitor to a terminal emulator. >The user will be able to interactively enter numbered program lines, >save/load the program to/from flash, execute the program, and run Basic >commands in immediate mode (non-numbered lines). It's meant to be a tool >for interactive experimentation of embedded concepts by non-programmer >types. I suppose it's much like a Basic Stamp. > >I know "free" and all those features above is a tall order but if I can find >an extensible package with some of those features it would be good too. > >Thanks, JJS
I was also similarly interested in something akin. 30 years ago I was part of those involved in writing a commercially used interpreter -- at the time, it was over timeshared service, though. The final result fit in 32k byte of the main cpu (which included 20k byte of swap space that did NOT include the interpreter, so the interpreter itself took up only 12kbyte) and used an I/O processor with 16kbyte of memory (most for buffers, not code.) This included pretty much everything one could want -- line number editing (just retype the linenumber with a line and it replaces the prior line) and pre-compilation into very fast code for interpretation. This meant all line numbers being replaced with addresses of the lines they referred to (no lookup), all variables being replaced with addresses into the variable table (no lookup needed), etc. It had to be, back then, so there the interpreter included an interpreter precompiler, an editor decompiler, the editor features, a variety of commands, support for all transcendentals, matrix math including inversion and determinants, and the execution engine, of course. Chebychev was used throughout the transcendentals, with minimax techniques to minimize accumulation of errors by setting constants appropriately, for very fast conversion and controlling error bounds rather than controlling average error, as does Taylor's, for example. I've considered the idea of doing it in a modern context for flash systems, but it was a lot of work and time (all coded in assembly for speed and compactness, which was vital then) and doing it all over again would not be easily considered. There is a definite niche for what you are talking about -- especially in education. I don't consider the Parallax BASIC Stamp to be anything close to as sophisticated, nor as useful for education., despite the fact that much better was achieved on slower processors and with less available code memory. But it may be the simpler choice at this time. You might also write some of the compiler vendors. A few of them may have developed a useful BASIC they couldn't really sell, but would be willing to part with. You'd need to be in a position to make modifications. If you find a worthy team to work on it, I'd be happy to share some of the details that turned out to work so well in the past -- I still have all the source code for it and I remember a great deal of the details, too. And I may be able to put in some time, as well. I applaud the idea. You will likely get some suggestions about Forth. I am no expert in it, only having small experiences with it (and enjoying the learning), but frankly I think you are on the right track for your target and I don't think Forth would serve it well. Jon
On Mon, 9 Mar 2009 11:18:56 -0700 (PDT), zwsdotcom@gmail.com wrote:

>On Mar 9, 2:04&#4294967295;pm, "John Speth" <johnsp...@yahoo.com> wrote: > >> Would anyone be able to recommend a free embedded basic interpreter with C >> source code? > >You investigated every option here? I see three at least that would >probably fit your needs: <http://www.thefreecountry.com/compilers/ >basic.shtml>
A quick skim follows. In it, I pretty much discount systems that require .NET, Windows, or other sophisticated operating systems. Often, their dependencies aren't merely surface but quite deep and not infrequently also require extensive graphics libraries to support their use of graphical interactions with the user. All of these make the useful parts very difficult to extract from the rest. So I discount them. There are a few possibilities that caught my eye, but I didn't investigate them further. There may be additional reasons that would have showed up to eliminate them, as well. For example, the OP mentioned "free embedded basic interpreter with C source code" and some of what remains may not fit that requirement. Microsoft SmallBasic: No, requires .NET and Windows Free Microsoft Visual Basic 2008 Express No, Windows. ThinBasic Basic Interpreter No, Windows. Chipmunk BASIC Interpreter No, Mac and PowerMac. XBLite - xbasic BASIC lite compiler No, requires Win32. Gambas - Gambas Almost Means Basic No, requires extensive operating system support under Linux, FreeBSD, and OpenBSD. And requires graphics. TNT Basic No, Mac and PowerMac. GLBCC - GNU / Liberty Basic Compiler Collection No, actually compiles -- not interpreter code. Among other issues. Mono's VisualBasic.NET Compiler (Mono Visual Basic Compiler) No, it's a cross-platform implementation of .NET with VB. Blassic Not sure. Maybe. FreeBASIC No, generates executables, not interpreted code. Just BASIC Maybe. Basic4GL No, Windows, OpenGL, etc. wxBasic Not promising. Probably not, but a weak maybe. SmallBASIC Maybe. MoonRock Compiler No, makes executables for MSDOS real-mode or DPMI. Mole BASIC Interpreter Not sure. Couldn't tell if it interprets, or not. Bas BASIC Interpreter Sounds more promising to me. ScriptBasic BASIC Interpreter No, back to Linux and Win32. Envelop Basic Compiler No, Windows. XBASIC BASIC Compiler No, Windows and Linux. Bywater BASIC Interpreter No, Linux. BCX BASIC Compiler No, makes c source code. Enhanced 6502 BASIC Maybe. UBASIC BASIC Interpreter No, different target (2500 digit math, for example.) YABASIC BASIC Interpreter No, Windows and Linux. ------------- Now, I'll add one of my own. There is the BASIC available for the 8031 core from Intel, "8052 BASIC." I don't consider it of much use, either, as it isn't in c. Jon

John Speth wrote:

> Hi everybody- > > This question comes up from time to time from various posters but it never > gets an answer that fits my specific needs. Here goes: > > Would anyone be able to recommend a free embedded basic interpreter with C > source code?
Why not making your own? It is not big deal to parse the trivial BASIC program flow and math. equations. The whole thing from scratch would take only several k lines of code. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
On Mon, 9 Mar 2009 11:04:03 -0700, "John Speth" <johnspeth@yahoo.com>
wrote:

>Hi everybody- > >This question comes up from time to time from various posters but it never >gets an answer that fits my specific needs. Here goes: > >Would anyone be able to recommend a free embedded basic interpreter with C >source code? > >My intended target is the STM32 which probably has enough RAM for small >programs. My intent is to create an embedded controller board with a serial >port that will expose a Basic interpreter/monitor to a terminal emulator. >The user will be able to interactively enter numbered program lines, >save/load the program to/from flash, execute the program, and run Basic >commands in immediate mode (non-numbered lines). It's meant to be a tool >for interactive experimentation of embedded concepts by non-programmer >types. I suppose it's much like a Basic Stamp. > >I know "free" and all those features above is a tall order but if I can find >an extensible package with some of those features it would be good too.
Does it have to be BASIC ? If not then LUA might be a good option. Regards Anton Erasmus
John Speth wrote:
> Hi everybody- > > This question comes up from time to time from various posters but it never > gets an answer that fits my specific needs. Here goes: > > Would anyone be able to recommend a free embedded basic interpreter with C > source code? > > My intended target is the STM32 which probably has enough RAM for small > programs. My intent is to create an embedded controller board with a serial > port that will expose a Basic interpreter/monitor to a terminal emulator. > The user will be able to interactively enter numbered program lines, > save/load the program to/from flash, execute the program, and run Basic > commands in immediate mode (non-numbered lines). It's meant to be a tool > for interactive experimentation of embedded concepts by non-programmer > types. I suppose it's much like a Basic Stamp. > > I know "free" and all those features above is a tall order but if I can find > an extensible package with some of those features it would be good too.
There is this: <http://www.cpustick.com/downloads.htm>. The BASIC interpreter is probably written i C, but it's not open source. There is a skeleton that is open source. I have a STM32 Primer1 and that could possibly run a BASIC interpreter. I think BASICs in C for Linux could be ported to embedded systems without to much trouble.
On Mon, 09 Mar 2009 21:29:47 +0100, "M.O.B. i L." <mikaelb@df.lth.se>
wrote:

>John Speth wrote: >> Hi everybody- >> >> This question comes up from time to time from various posters but it never >> gets an answer that fits my specific needs. Here goes: >> >> Would anyone be able to recommend a free embedded basic interpreter with C >> source code? >> >> My intended target is the STM32 which probably has enough RAM for small >> programs. My intent is to create an embedded controller board with a serial >> port that will expose a Basic interpreter/monitor to a terminal emulator. >> The user will be able to interactively enter numbered program lines, >> save/load the program to/from flash, execute the program, and run Basic >> commands in immediate mode (non-numbered lines). It's meant to be a tool >> for interactive experimentation of embedded concepts by non-programmer >> types. I suppose it's much like a Basic Stamp. >> >> I know "free" and all those features above is a tall order but if I can find >> an extensible package with some of those features it would be good too. > >There is this: <http://www.cpustick.com/downloads.htm>. The BASIC >interpreter is probably written i C, but it's not open source. There is >a skeleton that is open source. > >I have a STM32 Primer1 and that could possibly run a BASIC interpreter. > >I think BASICs in C for Linux could be ported to embedded systems >without to much trouble.
I would hope you are right. But wouldn't they tend to depend on more than just simple serial port I/O services for what they do? Sometimes, just the presence of an operating system and support facilities like X and POSIX _encourages_ their use, and in doing so entwines them. It's worth some looking, though. Jon
On Mon, 09 Mar 2009 22:28:40 +0200, Anton Erasmus
<nobody@spam.prevent.net> wrote:

>On Mon, 9 Mar 2009 11:04:03 -0700, "John Speth" <johnspeth@yahoo.com> >wrote: > >>Hi everybody- >> >>This question comes up from time to time from various posters but it never >>gets an answer that fits my specific needs. Here goes: >> >>Would anyone be able to recommend a free embedded basic interpreter with C >>source code? >> >>My intended target is the STM32 which probably has enough RAM for small >>programs. My intent is to create an embedded controller board with a serial >>port that will expose a Basic interpreter/monitor to a terminal emulator. >>The user will be able to interactively enter numbered program lines, >>save/load the program to/from flash, execute the program, and run Basic >>commands in immediate mode (non-numbered lines). It's meant to be a tool >>for interactive experimentation of embedded concepts by non-programmer >>types. I suppose it's much like a Basic Stamp. >> >>I know "free" and all those features above is a tall order but if I can find >>an extensible package with some of those features it would be good too. > >Does it have to be BASIC ? If not then LUA might be a good option. > >Regards > Anton Erasmus
I think the "non-programmer types" part of the OP's discussion points otherwise. Jon
Jon Kirwan wrote:

> You will likely get some suggestions about Forth. I am no expert in > it, only having small experiences with it (and enjoying the learning), > but frankly I think you are on the right track for your target and I > don't think Forth would serve it well.
Forth is nice for interactive development, but hard for new programmers, because you have to think about memory handling etc., which is much easier in Basic. But I don't see any reason why to use a dumb terminal interface. With wxWidgets a GUI can be developed which works on Windows, Mac and Linux, and even some portables and you need another PC or device anyway, if you want to use it with a serial port. The GUI could provide more modern file editing, debugger etc., instead of old-style C64 line numbers. BTW: I'm planning to develop such a system, too. What do you think of Modula-2? It is supposed to be more safe than Basic or C, but I don't know if it is easy for new programmers and if C or Basic programmers would like to use it. -- Frank Buss, fb@frank-buss.de http://www.frank-buss.de, http://www.it4-systems.de

The 2024 Embedded Online Conference