delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/23/17:05:21

Message-ID: <33F88098.11DA585@fcee.urv.es>
Date: Mon, 18 Aug 1997 19:04:24 +0200
From: Alexis Roda <arv AT astor DOT urv DOT es>
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: inline asm help
References: <33F5DDE3 DOT 43BC AT compuserve DOT com>
NNTP-Posting-Host: 195.5.77.74
Lines: 50
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Jason Meehan wrote:
> 
> int i=0,j=1,k=0;
> _asm__volatile_("
>  movl%1,%%eax\n
>  addl%2,%%eax\n
>  movl%%eax, %0"
> :"g=" (k)        ( I get an error here) error:parse error before ':'
> :"g"(i),"g"(j)
> :"ax","memory"
> );
> 
> The above is an example that I copied out of some docs, but I get the
> same problem with my own inline asm. Can anyone help me? Thanks

Write __asm__<space>__volatile__ (two underscores before and after asm
and volatile), add a space after the assembly opcode. I suggest you to
do something like:

  int i=0,j=1,k=0;
  __asm__ __volatile__ ("movl %1,%%eax\n\t"
			"addl %2,%%eax\n\t"
			"movl %%eax, %0"
			:"g=" (k)
			:"g"(i),"g"(j)
			:"ax","memory"
			);

enclose every line in quotes, and put \n and \t for proper indentation
of .S files (sometimes is useful to take a look at those files). If you
prefer to use only one pair of quotes enclosing all the assembly code
\n  is not required as long as you write every instruction in a
separated line:

__asm__ __volatile__ ("movl %1,%%eax
	addl %2,%%eax
	movl %%eax, %0"
	:"g=" (k)
	:"g"(i),"g"(j)
	:"ax","memory"
	);


Hope this works.


Saludos
Alexis Roda


- Raw text -


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