Re: gcc arm inline asm: how to output value for .set directive?

Liste des GroupesRevenir à ca embedded 
Sujet : Re: gcc arm inline asm: how to output value for .set directive?
De : invalid (at) *nospam* invalid.invalid (Grant Edwards)
Groupes : comp.arch.embedded
Date : 04. Apr 2025, 00:06:25
Autres entêtes
Organisation : PANIX Public Access Internet and UNIX, NYC
Message-ID : <vsn49h$4eg$1@reader1.panix.com>
References : 1
User-Agent : slrn/1.0.3 (Linux)
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...


Date Sujet#  Auteur
3 Apr 25 * gcc arm inline asm: how to output value for .set directive?3Grant Edwards
4 Apr 25 `* Re: gcc arm inline asm: how to output value for .set directive?2Grant Edwards
4 Apr 25  `- Re: gcc arm inline asm: how to output value for .set directive?1David Brown

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal