www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/06/21/00:22:06

Date: Wed, 21 Jun 2000 07:20:06 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk>
cc: djgpp AT delorie DOT com
Subject: Re: Inline asm: lcall & various binutils versions
In-Reply-To: <394FDC74.E8712E7F@phekda.freeserve.co.uk>
Message-ID: <Pine.SUN.3.91.1000621071322.8230C-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Tue, 20 Jun 2000, Richard Dawe wrote:

> #if GAS_MAJOR >= 2 && GAS_MINOR > 8
> 		 "nop	\r\n"
> #endif	/* IFDEFTEST */
> 		 "nop	\r\n");

I understand that this is just an example, because in the actual problem 
you had you will need a different condition for the versions (e.g., if 
GAS_MAJOR is 3 or more, GAS_MINOR is not important).

> Is this
> satisfactory? My sed knowledge is limited (*), but this seems to do the
> trick.

The Sed scripts can be improved slightly, but they seem to be correct.

> It took me a while to work out how to put #ifdefs in inline assembly. Eli,
> you probably knew this already, but: You have to rely on C's string
> concatenation.

For inline assembly, you need to rely on the preprocessor to do the 
trick when it works on the C source, so the #ifdef's need to be on the C 
level, not on the assembly level.

> [ If you put '#ifdef' in the inline assembly, then it becomes an assembly
> comment and does nothing.

AFAIK, inline assembly doesn't go through cpp; GCC emits it in the
form of preprocessed assembly.  So you cannot have any preprocessor 
directives inside the asm() block.

> This feels like less of a hack than relying on gas to generate the right
> code in spite of a warning.

More importantly, it's safer ;-)

- Raw text -


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