Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!apple!desnoyer
From: desnoyer@Apple.COM (Peter Desnoyers)
Newsgroups: comp.lang.c
Subject: Re: const, volatile, etc [was Re: #defines with parameters]
Message-ID: <21682@apple.Apple.COM>
Date: 5 Dec 88 17:18:51 GMT
References: <674@quintus.UUCP> <117@halcdc.UUCP> <468@auspex.UUCP> <9016@smoke.BRL.MIL> <10919@ulysses.homer.nj.att.com> <377@chem.ucsd.EDU> <21560@apple.Apple.COM> <13784@oberon.USC.EDU>
Distribution: eunet,world
Organization: Apple Computer Inc, Cupertino, CA
Lines: 26

In article <13784@oberon.USC.EDU> blarson@skat.usc.edu (Bob Larson) writes:
>In article <21560@apple.Apple.COM> desnoyer@Apple.COM (Peter Desnoyers) writes:
>>pet peeve - It is a common thing to have to write a zero to a device
>>register. The obvious code, (* reg_addr) = 0, often results in:
>>
>>  xor reg_addr, reg_addr
>
>What machine is this for? 
I'm pretty sure Turbo C on the PC does this. Even with optimization
off. I'll check. 

>Most 68000 compilers would use the
>clr instruction, which does have the undesired side effect of doing
>an (ignored) read though.
>
Almost as bad. The important point is that if these
micro-optimizations are performed in the compiler pass of a pre-ANSI
compiler, there is NO way to turn them off. Thus the naive view that
everything worked fine before ANSI started messing with the language
is demonstrably wrong.

>>...(please correct me if I'm wrong ... [whether volatile specifies
>>one write and no reads]
I stand corrected. Thank you.

				Peter Desnoyers