Mail Archives: djgpp/2000/04/15/13:03:44
Alexei A. Frounze wrote:
>Here goes a part of my project. I simply removed as much code as
>needed to leave it along.
I already replied to the same post, but after rethinking, I missed
a subtle and perhaps important point.
I do not know of any way, to tell gcc, how many registers on the
floating point stack you need. And this seems really to make
reliable inline assembly with floating point very difficult.
The reason is, that when not everything is written inline (you
have written almost all floating point in assembly), gcc might
want to leave some values in the floating point stack, when it
thinks, it can reuse them later. I cannot think of a way, how one
can see this from the source in general.
{
double x, y;
/* calc x somehow (1) */
/* assembler, uses all 8 FPU registers */
/* calc y */
x *= y; /* x is reused here, so gcc may keep it in st0 at (1) */
}
So, you might get a stack overflow.
It could also be, that using __asm__ volatile, together with
"memory" in the clobber list, will prevent gcc from considering
to cache those floating point values in the FPU, but I don't
know, and I can't remember seeing this mentioned anywhere.
You might consider to investigate this. Hopefully some readers
of this group do know more, or can suggest where the information
can be found.
There are "f" (floating point register), "t" (top of stack, st0) and
"u" (st1) constraints. But it seems difficult to work with those,
because the different registers "move" on the floating point
stack, when you use the floating point upcodes. So this is really
is much more complicated, then working with "normal" registers.
Regards, Dieter
P.S: Those semicolons after the if { }; blocks are not needed, and
may even become dangerous, when you need to change the source.
P.P.S: I have compiled parts of your code with the uncommented C code
instead of the inline assembly, and gcc -O seems to produce quite
efficient code.
- Raw text -