Groups | Search | Server Info | Login | Register
Groups > comp.arch.embedded > #32407
| From | Grant Edwards <invalid@invalid.invalid> |
|---|---|
| Newsgroups | comp.arch.embedded |
| Subject | Re: gcc arm inline asm: how to output value for .set directive? |
| Date | 2025-04-03 23:06 +0000 |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Message-ID | <vsn49h$4eg$1@reader1.panix.com> (permalink) |
| References | <vsn0lm$2k4$1@reader1.panix.com> |
On 2025-04-03, Grant Edwards <invalid@invalid.invalid> wrote:
> How do I convince ARM GCC's extended asm() to emit a value that can be
> used in a .set directive? Here's a simplified example:
> asm("\t.set foo_offset, %[off]" : : [off] "i" ( __builtin_offsetof(shm_t, foo) ) : );
That didn't work, because gcc emits #40 instead of 40:
> 35 .set foo_offset, #40
I finally stumbled across some example code that showed me the
answer. It's not the _constraint_ in the input operand list (the "i"
above) that matters (I had tried all upper/lower ascii letters).
You need a modifier in the _template_ string that references that
input operand:
asm("\t.set foo_offset, %c[off]" : : [off] "i" ( __builtin_offsetof(shm_t, foo) ) : );
The secret is the 'c' in "%c[off]"
Now that I know what to look for, I found it in the manual
https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Generic-Operand-Modifiers
6.11.2.8 Generic Operand Modifiers
I had completely missed the difference between a qualifier and a
modifier...
Back to comp.arch.embedded | Previous | Next — Previous in thread | Next in thread | Find similar
gcc arm inline asm: how to output value for .set directive? Grant Edwards <invalid@invalid.invalid> - 2025-04-03 22:04 +0000
Re: gcc arm inline asm: how to output value for .set directive? Grant Edwards <invalid@invalid.invalid> - 2025-04-03 23:06 +0000
Re: gcc arm inline asm: how to output value for .set directive? David Brown <david.brown@hesbynett.no> - 2025-04-04 11:25 +0200
csiph-web