Mail Archives: djgpp/2000/01/31/13:23:23
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 -