inline-assembly
Labels in GCC inline assembly
A declaration of a local label is indeed a number followed by a colon. But a reference to a local label needs a suffix of f or b, depending on whether you want to look forwards or backwards – i.e. 1f refers to the next 1: label in the forwards direction. So declaring the label … Read more
Looping over arrays with inline assembly
Avoid inline asm whenever possible: https://gcc.gnu.org/wiki/DontUseInlineAsm. It blocks many optimizations. But if you really can’t hand-hold the compiler into making the asm you want, you should probably write your whole loop in asm so you can unroll and tweak it manually, instead of doing stuff like this. You can use an r constraint for the … Read more
When to use earlyclobber constraint in extended GCC inline assembly?
By default, the compiler assumes all inputs will be consumed before any output registers are written to, so that it’s allowed to use the same registers for both. This leads to better code when possible, but if the assumption is wrong, things will fail catastrophically. The “early clobber” marker is a way to tell the … Read more