Mail Archives: djgpp/1997/04/21/03:25:02
On 21 Apr 1997 02:59:46 GMT, doing AT soback DOT kornet DOT nm DOT kr wrote:
> Hi,
>
> I use many inline assembly, but I got trouble with '-O3' option.
> My inline assemble functions are working well With -O2 or -O1.
>
> void Test( int count )
> {
> __asm__ ( "
> MyLoop:
> LOOP MyLoop"
> : : "g" (count) : "cx" );
> }
>
> int main( int argc, char *argv[] )
> {
> Test( 1 );
> Test( 2 );
> }
With `-O3' `Test' is inlined and this will result in
`MyLoop' label defined twice in `main', which is not
acceptable by assembler. Use `.' for referencing
current address.
Also, load `count' into ecx explicitely
(use "c" instead of "g").
inline void
Test (int _count)
{
__asm__ volatile ("loop ."
: : "c" (_count) : "%ecx");
}
Look at generated assembler input with gcc -S
- Raw text -