
Le 21/12/2010 13:35, Alexander Holler a écrit :
Hmm, is there actual somethinbg which should forbid the compiler to generate such code which rereads something? It might not be nice, but I don't think that it is forbidden for a compiler to do so. So the proper way to handle such, might be to use asm to avoid that the compiler touches that register.
Yes there is something that should prevent a compiler from inserting reads: these accesses are to hardware, not memory, and may cause side effects even on read (these could be acknowledges, for instance; I've seen instances of that myself on some HW).
Another way to look at it is that the semantics of " *ptr = value " is a pure write and should not result in a write-then-read.
Regards,
Alexander
Amicalement,