delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/07/05/18:34:16

Date: Thu, 5 Jul 2001 18:33:14 -0400
Message-Id: <200107052233.SAA11297@envy.delorie.com>
X-Authentication-Warning: envy.delorie.com: dj set sender to dj AT envy DOT delorie DOT com using -f
From: DJ Delorie <dj AT delorie DOT com>
To: djgpp AT delorie DOT com
CC: Niklas_Pson AT hotmail DOT com
In-reply-to: <90D5EC920NiklasPsonnospamhotm@130.235.20.4>
(Niklas_Pson AT nosmam DOT hotmail DOT com)
Subject: Re: Help!! Inline asm with DJGPP
References: <90D5EC920NiklasPsonnospamhotm AT 130 DOT 235 DOT 20 DOT 4>
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

The problem is that you're declaring cx to be both an input operand
and a clobber.  The solution, taken from linux's headers, is to
declare three temporary variables and match them as *outputs*, with
the constraints.  Then, make your input constraints be dups of those:

   int tmp1, tmp2, tmp3;
   asm volatile
   (
     "  cld ; "
     "  rep ; "
     "  movsl ; "
     : "=&S" (tmp1),
       "=&D" (tmp2),
       "=&c" (tmp3)
     : "0" (src_cur_line_pos),
       "1" (dest_cur_line_pos),
       "2" (c2)
     : "memory"
   );

The '=' means it's an output, '&' means that the value changes before
the instruction is done using its inputs, and '0'..'2' means "same
register as operand N".  The "volatile" tells gcc to never delete,
move, or modify the asm, else the optimizer would remove it (because
you're not using any of the output values).  The "memory" tells gcc
that the asm changes memory, so it should be pessimistic about
optimizing memory accesses around this asm.

- Raw text -


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