Mail Archives: djgpp/1997/12/17/18:15:24
"Mr R. Hopkins" <r.hopkins*@ic.ac.uk> writes:
> Hi there, I have an interesting problem:
> I am trying to write a short program which has some inline asm in gcc
> (either gcc on Linux or DJGPP on DOS). The problem I am having is
> passing a couple of floating point variables to the __asm__ part. What
> appears to happen when I use the suggested (by gcc info) method of:
> __asm__ (
> " fblahblah %1 \n"
> " faddstuff %%st(2), %%st(0) \n"
> " fldd %2 \n"
> " fstd %0 \n" /* etc. etc. */
> : "=r" (output_var)
> : "f" (input1), "f" (input2)
> : "%st" /* clobbers */
> );
>
> This approach does not work, since in lines (2)and (3) above notice how
> the floating point stack gets shuffled about. This causes the input
> param %2 to be further down the stack than expected, and so the value
> of %st which gcc inserts for param %2 is now incorrect.
> As a consequence, the code produces unexpecte (an undesireable) answers.
Passing floating point parameters to asm on the x86 isn't very well
documented in the info file. Get the source to gcc and read the
comment at the beginning of reg-stack.c. That explains how gcc
adjusts the fp stack according to the asm args.
--
Josh Vanderhoof (joshv AT planet DOT net)
- Raw text -