www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - BetterC working on AVR! (And a question about D)

reply AVR Dude <avr dude.com> writes:
I just found out that LLVM (7.0.1) has experimental support for 
AVR! This means that it is now (more or less) straightforward to 
use betterC on ATMEL microcontrollers.

Here are the basic steps to get it working:

1. Download the latest LLVM source.
2. Run CMake and pass the ` 
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="AVR" ` argument to CMake.
3. Compile the D source with LDC, passing the "-output-ll" and 
"-betterC" arguments to LDC.
4. Run llc passing the "-march=avr" and "-filetype=obj" arguments.
5. Done! You now have an AVR elf ready to be uploaded to a 
microcontroller.

Now, having gotten this far, I do have one problem: How can I 
access/modify CPU registers in D (for example, `_SFR_IO8(0x18)` 
in C)?

Could someone please help me to do this?

Thanks!
Mar 02 2019
parent rikki cattermole <rikki cattermole.co.nz> writes:
On 03/03/2019 4:15 PM, AVR Dude wrote:

snip

 Now, having gotten this far, I do have one problem: How can I 
 access/modify CPU registers in D (for example, `_SFR_IO8(0x18)` in C)?
 
 Could someone please help me to do this?
E.g. https://wiki.dlang.org/LDC_inline_assembly_expressions But you really need to talk with the LDC developers directly. This may require changes on LDC's end.
Mar 02 2019