delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/01/31/13:23:23

From: buers AT gmx DOT de (Dieter Buerssner)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: inline trouble
Date: 27 Jan 2000 14:51:10 GMT
Lines: 62
Message-ID: <86pm0u$325jc$1@fu-berlin.de>
References: <86i0tf$jnf$1 AT inf6serv DOT rug DOT ac DOT be> <86i2ub$jn8$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE>
NNTP-Posting-Host: dialup-212.162.13.216.frankfurt1.mik.net (212.162.13.216)
Mime-Version: 1.0
X-Trace: fu-berlin.de 948984670 3217004 212.162.13.216 (16 [17104])
X-Posting-Agent: Hamster/1.3.8.0
User-Agent: Xnews/2.11.08
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

broeker AT acp3bf DOT physik DOT rwth-aachen DOT de (Hans-Bernhard Broeker) wrote in 
<86i2ub$jn8$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE>:

>Hans Yperman <hyperman AT eduserv1 DOT rug DOT ac DOT be> wrote:
>
>> typedef unsigned char byte;
>> void repstosd(byte *to,int len,int val){
>>     asm("rep; stosl"
>>         ::"a" (val),"D"(to),"c"(len)
>>         :"%edi","%ecx");
>> }
>
>> inlines.c:5: fixed or forbidden register 2 (cx) was spilled for class
>> CREG.

I, and others too (i.e. grx), have found the same problem.
As was mentioned in this particular case, you might want to
use memset. Otherwise

void repstosd(byte *to,int len,int val){
    asm("rep; stosl"
        : "=D" (to), "=c" (len)
        : "a" (val), "0" (to), "1" (len)
        : "cc", "memory");
}

should work. (You may also want to clear the direction flag with cld).

>It's not a question of DJGPP, but of gcc version. 

Yes. So this forum may not be the correct one to discuss this, but ...

>gcc-2.95.2 is
>considerably less forgiving regarding not quite correct extended
>inline assembly than old gcc-2.8.1 was. You're not allowed to mark the
>same register both as 'input' and 'dirty', IIRC. 

I believe, you are correct. But it seems stupid to me, and is 
not compatible with older versions. Look at all those messages
about grx compiling not anymore. I also believe, it was not
documented in the past, that you must not clobber input registers.
I even think, that whoever reads the assembler section in the
old info file, will code exactly as Hans has done.
Only the info file for the latest compiler version has 
the noted restriction added. 
 
In the example of Hans, I think this is the most straightforward
and logical implementation of saying: put this in register x, then
work through my assembler instructions, after done assume that
register x changed. 

With gcc 2.95, you have to use the method in my example. This is much more 
error prone (in more complicated cases). I think this incompatible
change of gcc is very unforunate and should be rethought.
What are the reasons, that gcc 2.95 canīt treat the 2 code snippets
identically?

>The GCC home page has more details on this.

Do you have an URL for this?

Dieter.

- Raw text -


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