Groups | Search | Server Info | Login | Register
Groups > comp.arch.embedded > #32407
| Path | csiph.com!weretis.net!feeder9.news.weretis.net!panix!.POSTED.localhost!not-for-mail |
|---|---|
| From | Grant Edwards <invalid@invalid.invalid> |
| Newsgroups | comp.arch.embedded |
| Subject | Re: gcc arm inline asm: how to output value for .set directive? |
| Date | Thu, 3 Apr 2025 23:06:25 -0000 (UTC) |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Message-ID | <vsn49h$4eg$1@reader1.panix.com> (permalink) |
| References | <vsn0lm$2k4$1@reader1.panix.com> |
| Injection-Date | Thu, 3 Apr 2025 23:06:25 -0000 (UTC) |
| Injection-Info | reader1.panix.com; posting-host="localhost:::1"; logging-data="4560"; mail-complaints-to="abuse@panix.com" |
| User-Agent | slrn/1.0.3 (Linux) |
| Xref | csiph.com comp.arch.embedded:32407 |
Show key headers only | View raw
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