Comment # 16 on bug 126 from
(In reply to Johannes Pfau from comment #15)
> The classical hello world for these devices is usually blinking a LED
> (http://www.micahcarrick.com/tutorials/avr-microcontroller-tutorial/getting-
> started.html). This usually requires accessing two registers. Now if
> somebody asks us 'How does Hello World look like in D?' and we present a
> small D main function + 10 lines of ASM they'll laugh at us and will
> immediately stop considering D. It's the same for peek/poke.
> 
Nope, that would only be in the header/library that defines all those MM I/O
registers. Those "indirections" are used for any embedded programming. For
example in avr-libc you'll find this macro expansion.
GPIOA -> _SFR_MEM8(0x000A) -> _MMIO_BYTE(0x000A) -> (*(volatile uint8_t
*)(mem_addr)).
This expands to volatile, because volatile provides the correct semantics.
But you could as well expand it to some template in D which implements the
correct accesses.
This is what Michael did for ARM [1]. The only problem here is how to implement
volatile reads/writes semantically correct and with as little overhead as
possible. Currently he used shared for reading [2] and writing [3] and those
few places could as well be replaced with intrinsics or asm until intrinsics
are available.

https://github.com/JinShil/stm32_registers/blob/master/source/stm32/registers/rcc.d
https://github.com/JinShil/memory_mapped_io/blob/d19cefb42000cd06605ddf4d4d6b120670400144/source/mmio.d#L335
https://github.com/JinShil/memory_mapped_io/blob/d19cefb42000cd06605ddf4d4d6b120670400144/source/mmio.d#L402


You are receiving this mail because: