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

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2010-12-06 16:22:20
Hi!

On Mon, Dec 06, 2010 at 01:09:10PM +0100, Oliver Schmidt wrote:
> 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.

In fact it does. The standard says in "6.7.3 Type qualifiers" regarding
volatile objects::

  Therefore any expression referring to such an object shall be evaluated
  strictly according to the rules of the abstract machine, as described in
  5.1.2.3.

While 5.1.2.3 says:

  Accessing a volatile object, modifying an object, modifying a file, or
  calling a function that does any of those operations are all side effects,
  which are changes in the state of the execution environment. Evaluation of
  an expression may produce side effects. At certain specified points in the
  execution sequence called sequence points, all side effects of previous
  evaluations shall be complete and no side effects of subsequent evaluations
  shall have taken place.

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 Mon Dec 6 16:22:31 2010

This archive was generated by hypermail 2.1.8 : 2010-12-06 16:22:34 CET