Skip to contentSkip to conversation

How to use floating point in a module?

DISCUSSION [email protected] 2 participants 2 messages Jun 2, 2004

lore
Share & tools
lore
#0 lore raw

H. Peter Anvin replied to me:

Quoted 7 lines
Quoted 4 lines

(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.

#1 lore raw
Quoted 4 lines · 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....