Is there a good Basic interpreter?

Currently, I'm using the Mega 2560. But I already ordered a Due.

But as these sources evolve,

Life isn't supposed to be perfect.

DevilsChild:
I've seen bitlash before and to be honest, I don't like it. It has a weird syntax and only allows variables 27 from a-z.

27 variables from a-z. Clever !

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?

Is that somehow possible or does it sound ridiculous?

Yes on both counts.

Okay... But how can I execute a set of instructions, and how can I compile assembly code into binary code?

how can I compile assembly code into binary code?

The gcc compiler is really good at that.

That still leaves the question on how to execute a set of binary code on the Arduino. I think you need to add the instruction pointer on the stack, then excecute the binary code and at the end of that code pop esi and jump to it, right? Though I haven't found any examples yet...
Also, is it possible to compile asm on the Arduino?

Hmmm

"...lightweight interpreter..." , "... sources evolving...", "... life perfecting ..."

Of course!

....+++---> brainf*ck

Oh. And this guy has already written the interpreter for atmega:

Cheers,
John

That still leaves the question on how to execute a set of binary code on the Arduino.

The bootloader allows you to do that.

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.

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 :slight_smile:

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 <stdio.h>
#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%[Q<nbj
o)|gps)<<txjudi)m|aQdbtf!::::;sfuvso<aQefgbvmu;aQ<m,,a%CQ<csfbla%bQ<aN2!Q
\ndbtf!aP2Q;m>aP2Q<a%!D12J!JGJHJOJQJFJSJJJMHS%HD12D12N3!N4\nJUJT%UQm>aP4HC%T
Qs\q,,^>m,2aP4HC%SD12N1\nJNQm>s\..q^aHC%NHb%GN1!D32P3%RN1UP1D12JPQUaP1H
R%PN4\nQ<g\(aP3Q(^>aP2Q,2<n\(aP3Q(^>aP4Hb%OD12D12N2!N3\nJVP3Q,,<jg)aP3Q=>n
\(aP3Q(^m>g\(aP3Q(^<fmtf!m,,aHC%QN1!N1\nJ#Qqsjoug)#&e]o#-aP1QaHb%#Qqvut)
aP1Q
aHb%FN1\nQm>::::aHC%VP3Q>bupj)hfut)caHb%JD12JON1!Qjg)a%LN1UP1D12JIQUa
P1HL%IQ*m>aN2!N2\nP2Q<fmtf!m,,aHC%MN1!N2>P2Q>aN2\nP2Hbdd!b/d";k;char R[4][99]
;main(c,v)char
v;{char*p,*r,*q;for(q=s;*q;q++)*q>' '&&(q)--;{FILEi=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':Qr)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 <stdio.h>
#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%[Q<nbj
o)|gps)<<txjudi)m|aQdbtf!::::;sfuvso<aQefgbvmu;aQ<m,,a%CQ<csfbla%bQ<aN2!Q
\ndbtf!aP2Q;m>aP2Q<a%!D12J!JGJHJOJQJFJSJJJMHS%HD12D12N3!N4\nJUJT%UQm>aP4HC%T
Qs\q,,^>m,2aP4HC%SD12N1\nJNQm>s\..q^aHC%NHb%GN1!D32P3%RN1UP1D12JPQUaP1H
R%PN4\nQ<g\(aP3Q(^>aP2Q,2<n\(aP3Q(^>aP4Hb%OD12D12N2!N3\nJVP3Q,,<jg)aP3Q=>n
\(aP3Q(^m>g\(aP3Q(^<fmtf!m,,aHC%QN1!N1\nJ#Qqsjoug)#&e]o#-aP1QaHb%#Qqvut)
aP1Q
aHb%FN1\nQm>::::aHC%VP3Q>bupj)hfut)caHb%JD12JON1!Qjg)a%LN1UP1D12JIQUa
P1HL%IQ*m>aN2!N2\nP2Q<fmtf!m,,aHC%MN1!N2>P2Q>aN2\nP2Hbdd!b/d";k;char R[4][99]
;main(c,v)char
v;{char*p,*r,*q;for(q=s;*q;q++)*q>' '&&(q)--;{FILEi=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':Qr)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.