Re: [cc65] Optimizing code fails - Found the error!

Date view Thread view Subject view

From: Ullrich von Bassewitz (
Date: 2003-11-22 13:52:44

On Sat, Nov 22, 2003 at 01:18:14PM +0100, MagerValp wrote:
> void __irqhandler__ irq(void);

There was a discussion about this topic a long time ago. Problem is that
people would expect to be able to write a complete interrupt handler in C -
and this is not possible because of problems with the parameter stack.

I think I've found an easier solution, which is better than my first proposal:
The RTI instruction can be marked as "needs all registers on input" within the
optimizer, so it won't remove register loads preceeding RTI. However, there
may be other problems, for example with the function entry code: The compiler
knows that when a non fastcall function is called, the contents of the CPU
registers contain garbage, so a store of a register without a preceeding load
is at least suspicious.

> But putting the irq handler in its own assembler source file instead
> of using asm() isn't too much trouble.

Another workaround would be to place the interrupt handler into its own module
and translate this module without optimizations.



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 : 2003-11-22 13:53:02 CET