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

From: Groepaz <groepaz1gmx.net>
Date: 2010-12-07 15:33:53
On Dienstag 07 Dezember 2010, Ullrich von Bassewitz wrote:
> 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.

what about using an external symbol, the optimizer wont touch it then, right? 
ie define HWREG=$2000 in the linker config, then import that symbol and use it 
in the code ? shouldnt this work? :)

-- 

http://www.hitmen-console.org    http://magicdisk.untergrund.net
http://www.pokefinder.org        http://ftp.pokefinder.org

Trying to outsmart a compiler defeats much of the purpose of using one. 
<Kernighan & Plauger>

----------------------------------------------------------------------
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:34:42 2010

This archive was generated by hypermail 2.1.8 : 2010-12-07 15:34:45 CET