const, volatile, etc [was Re: #defines with parameters]

Bob Larson blarson at skat.usc.edu
Sat Dec 3 18:22:48 AEST 1988


In article <21560 at apple.Apple.COM> desnoyer at 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?  3 memory references for a simple clear
doesn't seem very good to me.  Most 68000 compilers would use the
clr instruction, which does have the undesired side effect of doing
an (ignored) read though.

>Unfortunately I don't think specifying bus semantics is within the
>purview of the ANSI committee (please correct me if I'm wrong - my
>knowledge of the details of the standard is limited) and volatile is
>not sufficient to force the desired activity.

Fortunatly you are wrong, and volitile is sufficient.


-- 
Bob Larson	Arpa: Blarson at Ecla.Usc.Edu	blarson at skat.usc.edu
Uucp: {sdcrdcf,cit-vax}!oberon!skat!blarson
Prime mailing list:	info-prime-request%ais1 at ecla.usc.edu
			oberon!ais1!info-prime-request



More information about the Comp.lang.c mailing list