News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

QWORDs with FPU

Started by indiocolifa, September 17, 2006, 06:59:55 AM

Previous topic - Next topic

indiocolifa

I'm writing small programs using QWORD types. I've found that instead of using the STDLIB math.hhf functions, you can easily manipulate quadwords using the FPU (loading with FILD) and storing later with FIST or FISTP.

Is this faster or slower than the STDLIB implementation?

raymond

Remember that FIST cannot be used to store a QWORD. You can only use FISTP for that data type.

Raymond
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

Randall Hyde

Quote from: indiocolifa on September 17, 2006, 06:59:55 AM
I'm writing small programs using QWORD types. I've found that instead of using the STDLIB math.hhf functions, you can easily manipulate quadwords using the FPU (loading with FILD) and storing later with FIST or FISTP.

Is this faster or slower than the STDLIB implementation?


The stdlib implementation of 64-bit operations are quite fast. Indeed, most of the time is actually spent passing the parameters and making the calls. The FPU, OTOH, is generally an order of magnitude or two slower because it does 80-bit floating-point arithmetic. Not exactly an efficient way to do 64-bit operations.

BTW, if speed is your main goal, I'd just do things like 64-bit addition and subtraction in-line. Multiplication and division are slow enough to justify the calls, but most other operations are so short (typically four instructions) that it's just better to do them in-line (or write macros if you really don't like to type). For 128-bit operations, the functions start to make a lot of sense.
Cheers,
Randy Hyde

Andrea Lanza

Hello,
sorry for my english.
I also use for my program 64-bit variable and an intensive logical bit operation.
I executing bit operation and copy operation into mmx register (mm0, mm1 ...)  with commands like pand, por, movq etc...
Is this reasonable fast or stdlib is better?

many thank's
Andrea Lanza

Randall Hyde

Quote from: Andrea Lanza on October 16, 2006, 06:19:44 PM
Hello,
sorry for my english.
I also use for my program 64-bit variable and an intensive logical bit operation.
I executing bit operation and copy operation into mmx register (mm0, mm1 ...)  with commands like pand, por, movq etc...
Is this reasonable fast or stdlib is better?

many thank's
Andrea Lanza


As long as you're not also using the FPU in your program, I'd use the MMX stuff. Assuming, of course, that you'll never need to run the code on a system that doesn't support MMX (pretty hard to find such a system these days).
Cheers,
Randy Hyde