H1 2015 Priorities and Bare-Metal Programming
Timo Sintonen via Digitalmars-d
digitalmars-d at puremagic.com
Mon Feb 2 09:56:40 PST 2015
On Monday, 2 February 2015 at 16:55:59 UTC, Andrei Alexandrescu
wrote:
> I think it's time to reopen that negotiation.
+1
> So does the argument boil down to better inlining control and
> enforcement? -- Andrei
If we reopen this I think we should start at the beginning and
not yet concentrate implementation details. The discussion should
not be developers against users. Developers make things _for_
users. If this was a commercial product, lack of listening users
needs would be fatal to the company.
The examples so far have been around a single register. There are
single registers in 8 bit processors. Modern 32 bit processors
have register banks that have tens of registers, 32 bit each.
They are accessed trough structs that may contain arrays,
substructs etc. It would be better that the solution we will
choose would apply to the whole structure and transitively to all
its members.
An example that is tyipcal in real use
1 regs.ctrl |= 0x20; // select some mode
2 regs.ctrl |= 0x1000; // transmitter on
3 foreach ( b ; buf ) // send a buffer of bytes
{
4 while ((regs.status & 0x40) ==0) {} // wait that the
transmitter is ready
5 regs.data = b; // send the byte
}
6 regs.ctrl &= ~0x20; // transmitter off
7 c=regs.data; // look if there is something to receive
In here the regs struc represents the registers of some peripheral
What the compiler thinks? 1 and 2 are removed because 6 will
overwrite the variable anyway. 4 may be moved before 3 because
status is not changed in the loop. The loop may be removed
totally because the last of 5 overwrites the previous anyway. 7
does not read the register because it uses cached data from 5
instead.
I want to use basio operators and language features to access
registers, not templates or functions or wrappers. I just hope we
have one word, that I will add to the definition of the register
struct and then the struct would behave as expected. I do not
care if it is a pragma or a keyword or a property or whatever,
but it has to be something in the definition and not something I
have to type every time I read or write a register.
More information about the Digitalmars-d
mailing list