Re: [cc65] How to force a read from a memory mapped register w/o volatile

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2010-12-07 15:01:55
On Mon, Dec 06, 2010 at 10:12:19PM -0600, Dave Dribin wrote:
> Keep in mind I don't know anything about the optimizer, would it be
> easier to optimize out a dummy variable?  i.e. is it difficult for the
> optimizer to realize in this code that the pusha/incsp1 is
> unnecessary?

In this special case it may be easy to detect. In the more general case, cc65
optimizations work on a too low level to detect such things easily.

> But.... I think I have found a good work around.  Using inline
> assembly + the 'bit' instruction seems to work.

It is a workaround, but not a good one. It works, because bit sets CPU flags
that the optimizer doesn't track, so it won't touch the instruction. This may
change in the future, so your code may stop working when compiled with
upcoming releases.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Dec 7 15:02:04 2010

This archive was generated by hypermail 2.1.8 : 2010-12-07 15:02:08 CET