Embedded Basic Interpreter

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
Reply to
Gary Pace
Loading thread data ...

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

Reply to
robertwessel2

Rowley Associates have a BASIC interpreter for the ARM:

formatting link

Leon

Reply to
Leon

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

formatting link

Reply to
Jim Stewart

Number of BASIC programmers vs. number of Tcl programmers?

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

Reply to
larwe

[...]

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.

formatting link

Regards, -=Dave

--
Change is inevitable, progress is not.
Reply to
Dave Hansen

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:

formatting link

and here's another version written in C:

formatting link

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

Reply to
mhahn

L > Regards,

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

Reply to
Leon

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

Reply to
Jim Stewart

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

Reply to
msg

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.

Reply to
Jim Stewart

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

Regards,

Michael Grigoni Cybertheque Museum

Reply to
msg

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.

Reply to
robertwessel2

programming

know

its

to/getting

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

Reply to
Peter Dickerson

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.

Reply to
KenLem

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

Reply to
Norm Dresner

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.

Reply to
KenLem

No, it doesn't: C has no select statement.

And you cannot use a better C compiler?

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 (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
Reply to
Hans-Bernhard Broeker

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.

Reply to
KenLem

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

Reply to
Anton Erasmus

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.