> I need store result of floating point calculation (in my example arctan()) in memory pointed by some variable. See this code:
> var a: single; pa: PSingle;
>   asm
>       fild dy
>       fild dx
>       fpatan
>       fstp a
>       fwait
>   end;
>   pa^ := a;
>
> It works, but is there any way how to store result directly to "pa^" in assembler ?
> I have tried:
>       ...
>       fpatan
> fstp pa^ ... fstp (pa) ... but this does not compile ... I need store to memory location pointed by pa "variable"
>       fwait
>   end;
>

You need to retrieve the value of pa into a register and then store at that address. Something like this:

=== code begin ===
mov edx, pa
fstp [pa]
=== code end ===


Thank you!
I have hoped, that there is some kind of direct usage. Because
"fstp a" is compiled into:
  fstps  -0x24(%ebp) // address of local variable "a" on stack
and "pa^ := a" into:
  mov    -0x4(%ebp),%eax
  mov    -0x40(%eax),%edx   // pa
  mov    -0x24(%ebp),%eax   // a
  mov    %eax,(%edx)             // a -> pa^

so I hoped, that there is possibility to do it directly :
  fstps  (-0x24(%ebp))
but seems that this construct (use address stored on address) is not supported by processors instructions at all. From performance POV result is same, so my optimalisation does not bring much effect. (and also make it portable from 32 to 64 bit brings problems as far as I expect, that "mov pa, edx" will not work as it should be on 64 bit "mov pa, rdx"
Thanks
-Laco.

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to