Re: Free Alternative to PicBasic?



D Yuniskis wrote:

Find a copy of the "BASIC 52" interpreter Intel used
decades ago in their masked 8052AH-BASIC part. This
is written in 8052 assembler. You can study how the
interpreter works and then *translate* it to the
processor of your choice.

This gives you exposure to a different class of processor
(8048/52), assembly language (on *two* processors) *and*
a "BASIC" that you can use on your ultimate target AS WELL
AS the knowledge of what's under the hood (so you could
modify it to add features that you might want).

I guess you've won the prize for the most difficult solution for his
problem :-)

I doubt Mike can do it, if he has already problems using C, e.g. installing
MPLAB and using an example from the free HI-TECH C compiler as the base for
his programs and reading the datasheet for calculating the values for the
baud rate registers instead of using some program magic for it. The only
limitation of the HI-TECH C compiler is that the code is not as optimized
as in the commercial version. It's really not that difficult, see e.g. this
simple project:

http://www.frank-buss.de/vco/

Or this preview of my latest project, a speed and time measurement device
with 200 us resolution (with a PIC18F252)

http://www.youtube.com/watch?v=qdZW1C5m5f0

The full source code and schematic is attached to the German article, which
are linked in the description of the video. It is one C file with 415
lines, including 50 lines for the 16x16 bitmap font. No libraries are used,
except the standard C libraries for sprintf and floating point handling
(yes, it is slow on the PIC and uses lots of flash, but it is no problem,
as the PIC18F252 has lots of flash and the calculations are outside the
interrupt).

You can't do projects with 200 us resolution with a BASIC interpreter. But
you could do it with a BASIC compiler. But this is more difficult than
writing an interpreter. You could start with writing a parser:

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

You can write the parser in BASIC, too. It is no problem to write a BASIC
parser in BASIC. But try it with something on and for the PC, e.g. Visual
Basic from .NET inside the free Visual Studio, because it is easier to test
and debug. Then you can try to enhance it to a parser and finally to a
compiler.

And buy the dragon book, if you want to learn how to write compilers,
because it is the standard book for this kind of stuff and helps you not
reinventing the wheel:

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

Much better for learning compiler design than reading an assembler
implementation of a BASIC interpreter :-)

--
Frank Buss, http://www.frank-buss.de
piano and more: http://www.youtube.com/user/frankbuss
.



Relevant Pages

  • Re: Best tools for writing an assembler?
    ... writing directly its C++ code. ... But this is the OP's first attempt at a relatively robust assembler. ... for hand written parser. ... Yes, but the result is less readable, the compiler does ...
    (comp.compilers)
  • Re: Metaphor-oriented programming
    ... assembler, and the only way out would seemingly be through. ... another level of abstraction. ... is the parser. ... compiler downwards, but having no firm ground to build on, and thus losing ...
    (comp.lang.misc)
  • Re: Best tools for writing an assembler?
    ... Keep in mind that there are both LR and LL parser tools. ... but we are talking about assembler syntax here. ... And a C++ compiler isn't a giant black box? ... level of understanding, both of the tool and it's expected input. ...
    (comp.compilers)
  • Re: Parser/ Interpreter
    ... Dann reicht ein endlicher Automat als Parser aus. ... Im Studium habe ich seinerzeit einen Compiler für ein Pascal-Subset ... ich bin dabei einen Interpreter für eine NC-Language zu ... Optional muss aber einschränken, Oftmals ist es so das alle ...
    (microsoft.public.de.german.entwickler.dotnet.vb)
  • Re: Whats lacking: a good intermediate form
    ... actually, even with rather poor assembler, one can still get within 2x ... A couple of tests I've just done with a 10-year-old compiler (with ... I'd put in the language got left out. ... being not just that I have to write an interpreter, ...
    (comp.compilers)