This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Need help on FPU division on 64 bit RHEL


Halesh S wrote:

> I am writing assembly level code for dividing two numbers.
> 
> The assembly function i used is
> 
> float  assm_div(float a1, float b1)
> {
>  float res;
>  __asm__ ("fld 8(%%ebp)"
>           :
>           :"a"(a1)
>          );
>  __asm__ ("fld 12(%%ebp)"
>          :
>          :"b"(b1)
>          );
>  __asm__ ("fdiv %st(1), %st");
>  __asm__ ("fstp -8(%ebp)"
>          );
>  __asm__ ("fstp -12(%ebp)"
>          );
>  return res;
> }
> 
> It works fine in Red hat 32 bit Linux, for the same its not working
> Red hat 64 bit Linux, on same hardware.
> 
> Is there any changes required for code to make work??

It'll have to be rewritten for x86_64, which has a different instruction
set.  But there are several bugs in the i386 version anyway: it works
only by accident.  Why do you not do

  return a/b;

?

Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]