www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/21/03:25:02

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
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


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