2004-06-02 06:06:15

by ndiamond

[permalink] [raw]
Subject: Re: How to use floating point in a module?

H. Peter Anvin replied to me:

>> (The CPU is an i686. I'll have to look up its opcodes and see if its
>> hardware will come close enough for everything the driver needs. If it
>> doesn't, I'll buy one of the books that some others kindly recommended
>> and do polynomial approximations.)
>
> On x86 (more specifically, on x87) if you can do it at all then you
> can do them all.

I'm not quite sure what that means. It was pretty easy to code a log2()
function using the built-in opcode, but it took me nearly a day to code
an exp2() function. The built-in f2xm1 opcode helps a lot but there's
no help for the other half exp2()'s lot.

I'm sure you and other x86 assembly experts can improve on this if
you ever have any need for it. The only consolation I get is that
for some reason gcc does library calls for log10 and pow. It would be
really trivial to inline log10, though maybe pow is too big to benefit
from inlining.


2004-06-02 19:31:29

by Valdis Klētnieks

[permalink] [raw]
Subject: Re: How to use floating point in a module?

On Wed, 02 Jun 2004 00:52:57 CDT, [email protected] said:

> I'm not quite sure what that means. It was pretty easy to code a log2()
> function using the built-in opcode, but it took me nearly a day to code
> an exp2() function. The built-in f2xm1 opcode helps a lot but there's
> no help for the other half exp2()'s lot.

I think what he meant was that if you get basic stuff like floating point
add and subtract, all the other opcodes like f2xm1 work as well. If there
isn't an opcode you're still have to build the code from the appropriate
primitives, of course....


Attachments:
(No filename) (226.00 B)