From: bukinm AT inp DOT nsk DOT su (Michael Bukin) Newsgroups: comp.os.msdos.djgpp Subject: Re: At inline assemble.. Date: Mon, 21 Apr 1997 07:20:36 GMT Organization: BINP SD RAS Lines: 37 Message-ID: <335b1224.16851577@news-win.inp.nsk.su> References: <5jel72$d9q$1 AT usenet DOT kornet DOT nm DOT kr> Reply-To: bukinm AT inp DOT nsk DOT su NNTP-Posting-Host: csd-bsdi.inp.nsk.su Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk 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