ARM bare-metal programming in D (cont) - volatile

Walter Bright newshound2 at digitalmars.com
Mon Oct 28 09:00:53 PDT 2013


On 10/28/2013 2:33 AM, eles wrote:
>> (For example, what really happens with a+=1 ? Should it generate an INC, or an
>> ADD, or a MOV/ADD/MOV triple for MMIO? Where do the barriers go? Do you even
>> need barriers? Should a LOCK prefix be emitted? How is the compiler supposed
>> to know just how the MMIO works on some particular computer board?)
>
> read [address] into registry (mov)
> registry++ (add)
> write registry to [address] (mov)
>
> You cannot do it otherwise (that is, a shortcut operator).

That overlooks what happens if another thread changes the memory in between the 
read and the write. Hence the issues of memory barriers, lock prefixes, etc.


> Since we discuss this matter, it could have been solved 10 times.

Pull requests are welcome!


More information about the Digitalmars-d mailing list