Re: [stella] Atari 2600 BASIC compiler

Subject: Re: [stella] Atari 2600 BASIC compiler
From: Kirk Israel <kirkjerk@xxxxxxxxx>
Date: Fri, 8 Jul 2005 16:50:39 -0400
On 7/8/05, Fred Quimby <c9r@xxxxxxxxxxx> wrote:
> You're right, I do know C but not perl, sed, awk or other language that
> might be easier.  I've only recently learned about lex/flex/yacc/bison and
> I've been reading up on them - I will definitely use these once I learn how.
>   If someone can help to get me started, that would be great - to start, I'd
> like to know how to get a parser going with these tools that accepts the
> line number, then a valid keyword or variable declaration for now so I can
> get a feel for how these tools work.

In thinking about this stuff further-- maybe a full blown parser is overkill.
I'm not sure if you WANT to support big expressions like

if x < 5 or ( x > 20 and p <> 0) then 

If you just wanted to support simple one condition conditionals, I
think you just need to add in a good tokenizer to toss away excess
white space.
> I've also thought about fixed point math.  I could set aside a few
> variables, or require them to be declared this way.  They would use one byte
> for the whole number and another byte for the decimal - they would be useful
> for fractional movement of objects across several frames.  I also plan to
> allow one to use any variable instead of just a-z, I just need to figure out
> how...!
traditionally basic makes users predeclare variables with 
One trick (though it doesn't make parsing any simpler!)  is to let
them declare any variables names they want (so long as they aren't
reserved words) and then just map them to traditional A-Z, if that's
helpful (but it would be useful if you could preserve the names they
give them)

Right now there's a very clean mapping between your variables and the
bytes of RAM they take up.  I think rather than reserving special
variables or having a different declaration, just having a few special
16 bit math functions that take multiple single-byte variables as
arguments will let you have the fractional stuff without worrying
about casting or any of that.   from fraction to integer or whatever.

Of course, I might be thinking ahead to this as a general purpose tool
that might have pluggable kernals, not just as a clean wrapper to the
single kernal you've provided
Archives (includes files) at
Unsub & more at

Current Thread