Is there a good Basic interpreter?

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.

De gustibus non disputandum est.

Good luck with your project. :)

-br

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.

You know, a reality check would be a good thing. Which Arduino are you using? Look at how much SRAM it has. The "code" to be interpreted has to fit in that space. Along with the interpreters variables.

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

http://hackaday.com/2013/01/29/genetic-algorithms-become-programmers-themselves/

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

http://www.omnimaga.org/index.php?topic=15152.0

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.

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.