Memory mapped IO

Lars T. Kyllingstad public at kyllingen.NOSPAMnet
Mon Jan 10 08:59:26 PST 2011

On Mon, 10 Jan 2011 08:38:15 -0800, Dan Olson wrote:

> "Lars T. Kyllingstad" <public at kyllingen.NOSPAMnet> writes:
>> On Sun, 09 Jan 2011 22:44:44 -0800, Dan Olson wrote:
>>> I'm exploring D for embedded work as a nice alternative to C/C++ for
>>> the 32-bitters and am finding it has a nice set of features.  But,
>>> what is the best way handle memory mapped IO?  I don't see volatile
>>> like in C. Is writing asm {} the best way to ensure memory access?
>>> Thanks,
>>> Dan Olson
>> Would std.mmfile be what you need?
>> -Lars
> Ok, thanks.  So I see that is a wrapper for mmap.  So that would be good
> for user space code running on top of posix or win32.  But...

Ah, I should have read your post more closely.  I just saw "memory mapped 
IO" and latched onto that. :)

> I'm more interested in the general embedded case with a small OS or no
> OS (just ISRs and main loop).  I'm betting without volatile, asm {} is
> the next best thing for tickling a controllers peripheral registers?
> Yes/No?
> I searched the news groups and saw there used to be a volatile.  But it
> looks like it was done away with because of how it was misused (like C
> volatile) for thread sharing.  But this is different.  This is just
> telling the compiler not to optimize away an access.

AFAIK, that's right.  The compiler does not optimise across asm {} blocks.


More information about the Digitalmars-d-learn mailing list