Assembler statements inside inline funntion
Jeffi Edward.J
j.jeffi@yahoo.co.in
Tue Dec 15 11:55:00 GMT 2009
Cedric Roux-4 wrote:
>
> 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.
>
>
I checked and it solves the problem. Thanks a lot :)
--
View this message in context: http://old.nabble.com/Assembler-statements-inside-inline-funntion-tp26789877p26791407.html
Sent from the gcc - Help mailing list archive at Nabble.com.
More information about the Gcc-help
mailing list