Re: Assembler statements inside inline funntion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jeffi Edward.J wrote:
>
> Hi,
>
> I have a doubt in embedded assembly code supported by GCC.
>
> Assume I have an inline function with some assembler statements embedded
> using asm().
>
> inline void fun()
> {
>    asm("mfmsr  %r3\n\t"
>        "loop:\n\t"
>        ...
>        ...
>        "bne loop\n\t"
>        ...);
> }
>
>
> If I call the inline function from two functions within same compilation
> unit,
> the label "loop" is present in both the functions. Since the label has scope
> throughtout
> the compilation unit, the assembler gives redefinition error for "loop".
>
> Is there any option to supply to compiler so that GCC generates unique label
> for "loop"
> across funcion? Or is it a limitation in GCC? or is it unusual to write asm
> statements
> inside inline function?
>
> Please clarify this.
>
> Thanks and regards,
> Jeffi
>

use 0, 1, ... (local labels)
like in:
    asm("mfmsr  %r3\n\t"
        "0:\n\t"
        ...
        ...
        "bne 0b\n\t"
        ...);

See: http://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html

Cédric.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux