From: j DOT aldrich6 AT genie DOT com Message-Id: <199603250147.AA209418472@relay1.geis.com> Date: Mon, 25 Mar 96 01:34:00 UTC 0000 To: djgpp AT delorie DOT com Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Subject: Re: Optimization causes error Reply to message 2241407 from BILL_CURRIE AT M on 03/24/96 5:12PM >> 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. >Alternatively, use local labels, ie [example deleted] >use b for backwards references and f for forward references. If I remember correctly (not being an assembly programmer myself), can't you just use the 'volatile' keyword with the function that contains the asm to prevent gcc from optimizing it? As I recall, 'volatile' tells gcc not tooptimize any given code/variable it is used with (in addition to its other uses).