EmbeddedRelated.com
Forums

ideas for a BASIC compiler

Started by Frank Buss June 1, 2008
In message <3bx08boy9vyb.3r6e0kbkdmfr$.dlg@40tude.net>, Frank Buss 
<fb@frank-buss.de> writes
>demonstrates that there is some use for BASIC on embedded systems. Which >language would you recommend, which is easy to use for beginners (so no C) >and can be compiled to small PICs?
I would recommend C for beginners. Otherwise they have to learn your BASIC then forget everything they have learned and learn c, C++, Ada or Pascal (?) and "real" tools as the next step. I cant see the point in learning something that is in a completely different direction to everything else and will have to be unlearned to progress. The problem is not al of it will be unlearned so it wil make matters worse long term. Rather than write your own version of BASIC use a cut down version of C..... Do a compiler that only does MISRA-C for example. -- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/ \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
Frank Buss wrote:
> I've started a BASIC compiler, first for PICs, but later I plan to use this > for ARM platforms, too. This is an example source code:
A quick scan on Sourceforge found this http://sourceforge.net/projects/gcbasic/ " Great Cow BASIC is an open-source BASIC compiler for Microchip PIC 10/12/16/18 series microcontrollers." So, why not align yourself with these efforts, and add the apparently missing Debug support, for example ? and also this : FreeBASIC Compiler http://sourceforge.net/projects/fbc/ Open-source, free, multi-platform BASIC compiler, with the syntax the most compatible possible with MS-QuickBASIC (incl. the GFX statements), but that adds new features such as pointers, unsigned data types, inline-asm, a pre-processor and many others. This seems to be a reasonably serious PC compiler, so trawl that for ideas. A pre-processor is a VERY good idea, as they allow block comments, and feature-version control. -jg
"AZ Nomad" <aznomad.3@PremoveOBthisOX.COM> wrote in message 
news:slrng46u5v.pse.aznomad.3@ip70-176-155-130.ph.ph.cox.net...
> On Mon, 2 Jun 2008 06:23:31 +0200, Frank Buss <fb@frank-buss.de> wrote: >>Robert Adsett wrote: > >>> Well if you *must* use basic :) > >>Usually I'm using C, but I think this would be too difficult for the >>beginner. > > Is the embedded application going to be in a playskool busibox? > Is that the target audience? > > Anybody who can figure out how to incorporate an embedded processor can > figure out how to use a real programming language or find somebody who > can.
No, there's plenty of hardware engineers that can't program in HLL. I can do excellent assembler in AVR/51, but could never get to grips with c/pascal etc, but BASIC no problem.... just.
Chris H wrote:
> Rather than write your own version of BASIC use a cut down version of > C..... Do a compiler that only does MISRA-C for example.
There is a language called NQC (Not Quite C) for the Lego Brainstorms sets, which might also be worth looking into. -- Pertti
On Mon, 2 Jun 2008 06:31:06 +0200, Frank Buss <fb@frank-buss.de> wrote:
>AZ Nomad wrote:
>> Lovely. Pick a language that in it's 'standard' form is too much of a piece >> of shit to do anything useful. Pick a language that has to be extended to >> the point of being incompatible with the other thousand varients calling >> themselves basic. Where can I sign up? I really want a language that won't >> permit me to reuse any of of my code and which won't work with any previously >> developed libraries.
>Usually you don't need previously developed libraries for small embedded >systems and products like this:
Oh, really? You never have to interface to any other devices? You write all your interface code?
On Mon, 2 Jun 2008 00:42:24 +0200, Frank Buss <fb@frank-buss.de>
wrote:

>I've started a BASIC compiler, first for PICs, but later I plan to use this >for ARM platforms, too. This is an example source code:
Why go for a compiler. The advantage of BASIC has been the trial'n error learning with an interpreter. Said this, there is e.g. tiny-BASIC. -- 42Bastian Do not email to bastian42@yahoo.com, it's a spam-only account :-) Use <same-name>@monlynx.de instead !
On Jun 2, 2:54 am, "TT_Man" <Some...@ntlworld.com> wrote:
> "AZ Nomad" <aznoma...@PremoveOBthisOX.COM> wrote in message > > news:slrng46u5v.pse.aznomad.3@ip70-176-155-130.ph.ph.cox.net...> On Mon, 2 Jun 2008 06:23:31 +0200, Frank Buss <f...@frank-buss.de> wrote: > >>Robert Adsett wrote: > > >>> Well if you *must* use basic :) > > >>Usually I'm using C, but I think this would be too difficult for the > >>beginner. > > > Is the embedded application going to be in a playskool busibox? > > Is that the target audience? > > > Anybody who can figure out how to incorporate an embedded processor can > > figure out how to use a real programming language or find somebody who > > can. > > No, there's plenty of hardware engineers that can't program in HLL. I can do > excellent assembler in AVR/51, but could never get to grips with c/pascal > etc, but BASIC no problem.... just.
IOW plenty of hardware engineers who are not also software engineers. Software engineering is a different disipline. Embedded software engineering even more specialized. Didn't dykstra say something like BASIC will ruin your mind for programming? Ed
"42Bastian Schick" <bastian42@yahoo.com> wrote in message 
news:4843d355.7086439@news.individual.de...
> On Mon, 2 Jun 2008 00:42:24 +0200, Frank Buss <fb@frank-buss.de> > wrote: > >>I've started a BASIC compiler, first for PICs, but later I plan to use >>this >>for ARM platforms, too. This is an example source code: > > Why go for a compiler. The advantage of BASIC has been the trial'n > error learning with an interpreter. > > Said this, there is e.g. tiny-BASIC. >
Have both...... play with the interpreter, run with the compiler. :)
On Mon, 02 Jun 2008 11:04:36 GMT, bastian42@yahoo.com (42Bastian
Schick) wrote:

>Why go for a compiler. The advantage of BASIC has been the trial'n >error learning with an interpreter. > >Said this, there is e.g. tiny-BASIC.
There is no reason why an interpreter (interactive) should not compile performant code. The restriction for an embedded system is in Flash and RAM resources to contain the optimising compiler. Many Forth systems use a tethered approach. The PC is used for the interactivity; the embedded system only contains the required runtime and a tiny message-passing monitor. Current single-chip ARMs have enough resources to contain our VFX code generator, but I wouldn't want to do this on a small PIC. Stephen -- Stephen Pelc, stephenXXX@mpeforth.com MicroProcessor Engineering Ltd - More Real, Less Time 133 Hill Lane, Southampton SO15 5AF, England tel: +44 (0)23 8063 1441, fax: +44 (0)23 8033 9691 web: http://www.mpeforth.com - free VFX Forth downloads
"Frank Buss" <fb@frank-buss.de> wrote in message 
news:vy0visejb8py$.1okedkurk85cw$.dlg@40tude.net...
> I've started a BASIC compiler, first for PICs, but later I plan to use > this > for ARM platforms, too. This is an example source code: >
Why bother re inventing the wheel? MikroElektronika produce an excellent Basic compiler for PIC/AVR/8051 variants. You can incorporate your own assembler code within it, and it has a full suite of math/floating point/I2C/SPI/UART etc librarys supplied as standard. Costs around $150 and its yours, or if you are producing less than 2k of code - its entirely FREE. I personally have used this - not for a micky mouse product but a full blown image processing application performing intelligent interactive control of a large FPGA. http://www.mikroe.com/en/compilers/mikrobasic/pic/ Icky