www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/03/24/17:20:10

Message-Id: <s1567195.051@MAIL.TAIT.CO.NZ>
Date: Mon, 25 Mar 1996 10:12:42 +1200
From: Bill Currie <bill_currie AT MAIL DOT TAIT DOT CO DOT NZ>
To: djgpp AT delorie DOT com
Subject: Re: Optimization causes error?

On 23/3/96  9:54 pm, Fabian Nunez <fnunez AT cs DOT uct DOT ac DOT za> did thus say >>>
> 
> 
> This happens because the -O3 option goes berserk, inlining everything
> it can. Unfortunately the inline asm does not touch the labels you
> provide, so if you call your asm routine more than once in your code
> there is more than one copy of your asm routine in the asm file generated
> (compile with -S to see it). The solution is to simply write your asm
> function in a different source file to the one it is used in (maybe 
> asmstuff.cc). In this way the compiler cannot inline your asm (since it 
> ends up in a different .o file) and your problem is solved.
> 
> (maybe this should be in the FAQ, it's kindof an annoying feature of GCC)

Alternatively, use local labels, ie

asm(
" 1:
  decl %ecx
  jnz 1b"
);  

use b for backwards references and f for forward references.

Bill


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019