Is there a good Basic interpreter?

I know, but I meant from within running code, like this:

void setup()
{
    char *binary = .....
    push esi
    execute(binary);
    pop esi
}

Forth might be a good option: http://arduino.cc/forum/index.php/topic,8838.0.html

DevilsChild: Got another idea: What about an assembly compiler on the Arduino? Pass ASM code as string and get binary code as return and then execute it by setting the instruction pointer? Is that somehow possible or does it sound ridiculous?

Not possible. On these processors (Harvard architecture) you can't execute code from RAM.

http://en.wikipedia.org/wiki/Harvard_architecture

DevilsChild: Got another idea: What about an assembly compiler on the Arduino? ....

Do you mean ON the Arduino or FOR the Arduino?

I meant on the Arduino from memory. Well, as Nick stated, it is not possible. I think I'm best off by writing my own Basic interpreter. It shouldn't be so hard, I've written one a couple of years ago. When something useful comes around, I'll share it :)

Again, thank you all for help. I will also take a closer look at bitlash and some of the posted links.

Here is one:

include

define Q r=R[*p++-'0'];while(

define B ;break;case

char*s="Qjou!s\311^-g\311^-n\311^-c\::^-q-ma%mO1JBHm%BQ-aP1J[O1HB%[QaP2QaP4HC%T\ Qs\q,,^>m,2aP4HC%SD12N1\nJNQm>s\..q^aHC%NHb%GN1!D32P3%RN1UP1D12JPQUaP1H\ R%PN4\nQaP2Q,2aP4Hb%OD12D12N2!N3\nJVP3Q,,n\ \(aP3Q(^m>g\(aP3Q(^::::aHC%VP3Q>bupj)hfut)caHb%JD12JON1!Qjg)a%LN1UP1D12JIQUa\ P1HL%IQ*m>aN2!N2\nP2QP2Q>aN2\nP2Hbdd!b/d";k;char R[4][99] ;main(c,v)charv;{char*p,*r,*q;for(q=s;*q;q++)*q>' '&&(*q)--;{FILE*i=fopen(v [1],"r"),*o=fopen(q-3,"w");for(p=s;;p++)switch(*p++){B'M':Q(k=fgetc(i))!=EOF &&k!=*p)*r++=k;if(k==EOF){fputs("}}\n",o);fclose(o);return system(q-6);}*r=0 B'P':while(*p!='`')fputc(*p++,o)B'O':Q*r)fputc(*r++,o);p--B'C':k=0;Q k<*p-'0' )(*r++=fgetc(i),k++);*r=0 B'I':k= *p;if(*R==k)goto G B'G':k= *p;G:p=s;while( *p!='$'||p[1]!= k)p++;p++B'N':R[*p-'0'][0]++;}}}

8^)

I used to code in Visual Basic 6 for a living... hopefully never again. I've slowly evolved to languages that actually work and make sense.

It shouldn't be so hard

Nothing is difficult, until you start doing it.

KeithRB: Here is one:

include

define Q r=R[*p++-'0'];while(

define B ;break;case

char*s="Qjou!s\311^-g\311^-n\311^-c\::^-q-ma%mO1JBHm%BQ-aP1J[O1HB%[QaP2QaP4HC%T\ Qs\q,,^>m,2aP4HC%SD12N1\nJNQm>s\..q^aHC%NHb%GN1!D32P3%RN1UP1D12JPQUaP1H\ R%PN4\nQaP2Q,2aP4Hb%OD12D12N2!N3\nJVP3Q,,n\ \(aP3Q(^m>g\(aP3Q(^::::aHC%VP3Q>bupj)hfut)caHb%JD12JON1!Qjg)a%LN1UP1D12JIQUa\ P1HL%IQ*m>aN2!N2\nP2QP2Q>aN2\nP2Hbdd!b/d";k;char R[4][99] ;main(c,v)charv;{char*p,*r,*q;for(q=s;*q;q++)*q>' '&&(*q)--;{FILE*i=fopen(v [1],"r"),*o=fopen(q-3,"w");for(p=s;;p++)switch(*p++){B'M':Q(k=fgetc(i))!=EOF &&k!=*p)*r++=k;if(k==EOF){fputs("}}\n",o);fclose(o);return system(q-6);}*r=0 B'P':while(*p!='`')fputc(*p++,o)B'O':Q*r)fputc(*r++,o);p--B'C':k=0;Q k<*p-'0' )(*r++=fgetc(i),k++);*r=0 B'I':k= *p;if(*R==k)goto G B'G':k= *p;G:p=s;while( *p!='$'||p[1]!= k)p++;p++B'N':R[*p-'0'][0]++;}}}

8^)

CODE TAGS!!!!

dhenry:
Nothing is difficult, until you start doing it.

The mind boggles. Truly.

A maybe 10 second search got this: http://amigojapan.github.com/Arduino-Retro-Computer-with-SD-card-and-LCD-display-and-Keyboard-input-with-BASIC-interpreter/

and this: http://hackaday.com/2012/05/01/arduino-basic-interpreter-using-lcd-keyboard-and-sd/

and this: http://ec2-122-248-210-243.ap-southeast-1.compute.amazonaws.com/mediawiki/index.php/Arduino_Basic

and a few more before results from this forum made the list. Your mileage may vary.

Interpreter Basic is a ancient and cruel form of torture supported by masochists and the ingnorant.

Interpreter Basic is a ancient and cruel form of torture supported by masochists and the ingnorant.

Mostly the latter.

Pass the code as string and the library executes it? I don't necessarily need the shell that many interpreters provide

BASIC is sorta all about the shell...

As for the provided code, it didn't work! And it's obvious that that is not actually a basic interpreter, but only a "compiler" that translates BASIC code into C code! And it needs more comments! ( http://forum.basicprogramming.org/index.php?topic=1824.0;wap2 Follow the links...)

PaulS:

Interpreter Basic is a ancient and cruel form of torture supported by masochists and the ingnorant.

Mostly the latter.

And I actually heard that they encourage the use of GOTO statements. ;)

Yup. When your business package crashes you maybe load a variable or two and type GOTO some-line-number to keep running. Ain't life good?

Interpreter Basic is a ancient and cruel form of torture supported by masochists and the ingnorant.

A joke I'm sure, but don't be so dismissive. A tiny number of us were assembling back in the day, an increasing number of people who had to have abstraction used proto C (You talk about torture - they loved error reports), but there was a mass of people who were introduced to microprocessors via Basic (go find the philosophy behind it's development), Fortran, Pascal (later) forth etc. ALL of those pioneers provide the shoulders that we now stand on. The C used in Arduino is stripped down and has to be the easiest implementation I have ever come across and yet it still throws errors from artefacts, at least Basic has the good manners to point out the error and only the error ;) And what exactly is wrong with a goto? It just provides a method for stepping over code, structures like 'case' do the goto's for you. In fact, if you read the reference, you'll find a goto. Anyone can write sloppy code in any language. If you want to be dogmatic and write tight code, pick up the data sheet and start assembling.

The advocates of all languages look down their noses at the other language users, however, if you see someone smiling quietly to himself, trying not to look too aloof, he'll be the assembler in the room ;)

For a real insight, writing languages (and even small OS's) is fun, everyone should try it.

if you see someone smiling quietly to himself, trying not to look too aloof, he'll be the assembler in the room

No, he'll be the real engineer, who has tweaked the microcode 8)

he'll be the assembler in the room

I thought for a moment you said "elephant in the room". ;P

People paid me to write Basic on and off from 1980 to 1999 (last Y2K maintenance). I would BEG them to let it be C or Forth and they'd insist that if it was Basic then it would be more maintainable. Well at least by 85 it was compiled Basic. Interpreter Basic is missing so much it is cruelty to work with. Compiler Basic is less so in proportion to how much it is C/C++ in disguise. I speak from a lot of experience!

Every time I'd get into assembler it seemed like no time before the new chips were out. I did some segments for pay and more for learning but as compilers got really good I said to hell with it. I wasn't making my living keeping with the latest. If anyone is then I'm happy for you, good on yer!

Basic was like a bad habit with no redeeming qualities that I couldn't find in a better, more capable language.

what exactly is wrong with a goto?

It doesn't provide inferior people the ability to feel otherwise.