Is anyone aware of a very good, technical description of avr-gcc inline asm? It took me only a few months to learn straight asm (i.e. write main.S, compile with avr-gcc), but after years of AVR 8-bit development I still haven't mastered inline asm.
I've read the official docs numerous times:
I've read lots of code examples with inline asm, and a few blog posts such as Jim Eli's:
While generally helpful, it's littered with mistakes such as using "=r" with "ldi" (which means the constraint should be "=d" instead).
Much of what I've learned is through slow trial and error looking through disassembled code. Sometimes I figure out how something works, and despite working consistently across different compiler versions, I wonder if it will change in the future.
Other times it does things (particularly with register allocation and use) that makes no sense to me, and may even be bugs.
For a specific example of the kind of things I'm trying to do with inline asm, I wrote a blog post a few years ago about lightweight asm wrappers.
It's now four years later, and I still haven't figured a way to get the compiler to use r24 for an input parameter. i.e.
asm volatile ("rcall _foo" :: "r24" (arg));
So has anyone found an avr-gcc guru that has written down the secrets of inline assembler?