const, volatile, etc [was Re: #

mcdonald at uxe.cso.uiuc.edu mcdonald at uxe.cso.uiuc.edu
Sun Dec 4 01:59:00 AEST 1988



>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

>even with optimization off. This sucks - it reads the register twice,
>XORs the two (possibly different) values, and then writes the possibly
>non-zero value. 

Oh my. This really is a disaster. Is this legal behaviour? ANSI
people, what about it.

(Luckily my machine can't xor memory with itself - or subtract it.
But it can increment it or decrement.)



More information about the Comp.lang.c mailing list