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