RE: [stella] Atari 2600 BASIC compiler

Subject: RE: [stella] Atari 2600 BASIC compiler
From: "B. Watson" <atari@xxxxxxxxxxxxxx>
Date: Thu, 7 Jul 2005 21:18:29 -0400
On Thu, 7 Jul 2005, Fred Quimby wrote:

>> Works OK on Linux. One thing I noticed (that would affect DOS/Windows
>> too) is that 2600basic.h tries to include itself (contains "include
>> 2600basic.h").  That caused DASM to freak out a bit...
> Thanks, I was getting some strange warnings in DASM of which I didn't know
> the cause, and this fixed it.  DASM still assembled sucessfully anyway so I
> didn't try to find the problem.  Apparently DASM is tolerant of incorrect
> code!

It's always been tolerant of wrong code: it allows stuff like:

label ds #1   ; BZZT! # means "immediate addressing mode",
               ; which is meaningless here

In this case it kept recursively including 2600basic.h until it hit an
internal limit, then claimed it couldn't open the file... interestingly
enough, adding "-v3" to the command line caused it to fail with an error
instead of just warnings.

Actually, it wouldn't be a bad idea for the next version of DASM to error
out if a file tries to include itself. I can't think of any useful use
for it; seems like it'd always be an accident...

You could also have avoided it with "include guards" like C/C++ headers use.

; Untested code, some assembly required :)

  ifnconst MY_INCLUDE_H ; first line of file "my_include.h"


  include "whatever.h"
  include "my_include.h"  ; Whoops!

; ...
; included code (maybe tons of it)

  endif ; last line of file

So long as your included code lies between the "ifnconst" and "endif", you'll
be fine, even if your .h file tries to include itself.

Some people consider this sloppy: it hides the error rather than fixing it.

Archives (includes files) at
Unsub & more at

Current Thread