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

From: Oliver Schmidt <ol.sc1web.de>
Date: 2010-12-06 13:09:10
Hi Dave,

> {
>   IO_Read8(0x2002);
>   IO_Write8(0x2006, 0x20);
>   IO_Write8(0x2006, 0x00);
> }

> Unfortunately, the IO_Read8() is being optimized out when compiled with -Os:

> Typically the 'volatile' keyword tells the compiler not to perform
> this optimization.

I don't agree at all. The 'volatile' keyword tells the compiler not to
cache values read but to rather presume they might have beeen changed
at any time (by other threads, ISRs, MM I/O, ...). The 'volatile'
keyword does *not* tell the compiler that any read/write may have side
effects necessary and therefore needs to be performed always.

Regards,
Oliver
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Mon Dec 6 13:09:16 2010

This archive was generated by hypermail 2.1.8 : 2010-12-06 13:09:18 CET