H1 2015 Priorities and Bare-Metal Programming

Iain Buclaw via Digitalmars-d digitalmars-d at puremagic.com
Sun Feb 1 23:16:27 PST 2015


On 2 Feb 2015 05:50, "Walter Bright via Digitalmars-d" <
digitalmars-d at puremagic.com> wrote:
>
> On 2/1/2015 9:21 PM, Daniel Murphy wrote:
>>
>> "Walter Bright"  wrote in message news:mam6qe$15nu$1 at digitalmars.com...
>>>
>>> > We also need a pragma(address) to complement pragma(mangle).
>>>
>>> What would that do?
>>
>>
>> It would allow naming a memory address, similar to using .org in
assembly.
>>
>> eg
>> pragma(address, 0x0025)
>> shared ubyte PORTB;
>> static assert(&PORTB == cast(ubyte*)0x0025);
>>
>> This is a much nicer version of C's
>> #define PORTB (*(volatile unsigned char *)0x0025)
>
>
> That's what I suspected :-)
>
>   struct Ports {
>     static ubyte B() { return volatileLoad(cast(ubyte *)0x0025); }
>     static void B(ubyte value) { volatileStore(cast(ubyte *)0x0025,
value); }
>   }
>
>   ...
>   Ports.B = 7;
>   foo(Ports.B);
>
> gets the job done. Of course, you could take it further and make a
template out of it:
>

Where is the @property?  :)

Iain.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20150202/ea7ad603/attachment-0001.html>


More information about the Digitalmars-d mailing list