Re: [cc65] Bug Hunting Odysee

Date view Thread view Subject view

From: Ullrich von Bassewitz (
Date: 2002-07-11 21:31:02


On Thu, Jul 11, 2002 at 08:51:05PM +0200, groepaz wrote:
>    YES... a quick hack inside cl65 proves it.... it doesnt pass -O
>    flags at ALL !!!
>    PHEW... and the solution is so easy, just never put any switches
>    after filenames .. doh :~] this has probably caused other problems
>    before aswell, argls ;/

There are many command line tools out there that process the command line from
left to right. For a compiler that could mean that -O remembers the flag, and
the occurrance of a file name compiles that file. Now, if the file name comes
first, and then the -O flag, the file is first compiled and then the -O switch
is remembered for later...

So a general rule (not only for cc65) is that options should always preceed
file names on the command line if the docs do not say that it is ok the other
way round. The order is also clearly stated in the output of the --help

	uz_at_trixie:~/tmp$ cl65 --help
	Usage: cl65 [options] file

Note the order: 1.  2.        3.

Now the good news: All tools that take just one file name will accept an
arbitrary position of the options. The file name is remembered and the file is
processed when the command line is parsed completely. For tools taking any
number of file names (cl65 comes to mind) this is more overhead, because an
unknown number of file names must be remembered. So these tools process the
files when they appear on the command line, which means that any options
occuring behind the name are still processed but have no effect when
processing files that preceed it.

I hope this explains why things are as they are :-)

>    ok, so now this should have really been it.... i changed all my
>    environment to always put filenames last on the command line and i
>    use -Ors now..... looks like this fixes most of the problems i had,
>    cheers :o)

Good to hear that :-)

> ok, for the -Oi bug its your turn now i guess :o)

The base routine for printf() contains a

	jmp	(ind)

command. The linker should warn if the argument address crosses a page
boundary, but it does not. Your code seems to trigger that bug. Please try to
reorder the array program (move the f() and g() functions before main() in the
source) and recompile it with the command line switches that were not working.
If the program works now, it is the bug described above. I have already fixed
the problem in the development version (using jmp (ind) is never a good idea,
even with a linker extension, because there are output formats - o65 for
example - where the final address is not known).

> 1) in cl65 cmdline-help is a typo.... it should be "compile and
>    assemble" not "Compiler ..." :=D

Thanks, fixed!

> 2) there should be an easy way to let cl65 print the commandline it
> uses to call sub-processes. would have saved me some time atleast i
> guess :o) (i quickly hacked it to do that actually ;=P)

Good idea. I will output this information when the -d (debug) switch is used.



Ullrich von Bassewitz                        
To unsubscribe from the list send mail to with
the string "unsubscribe cc65" in the body(!) of the mail.

Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2002-07-11 21:31:07 CEST