How exactly do you use the fabs instruction, or is that outdated? Is it better to use something else (i.e. your own function or macro) to get an absolute value?
Posted on 2001-11-25 23:18:33 by Will
I didnt look up in my asm book, but I think it does simply:

st(0) = | st(0) |
Posted on 2001-11-26 05:45:10 by beaster
I'm pretty sure thats it, of course if you want to write you're own MACRO it would be pretty simple:

fmul st,st
fsqrt

But thats probably over a hundred times slower than fabs :grin:
Posted on 2001-11-26 05:52:37 by Eóin
If you have the floating point stored in memory you can do this:



mov eax, [floatVal]
and eax, 0x7FFFFFFF
mov [floatVal], eax


ift only works on real4 floats (not doubles).

If the value is in the FPU stack then use fabs.
Posted on 2001-11-26 08:32:22 by dxantos
dxantos, that could would probably work on qwords and even tbytes, just grab the highest four bytes and the sign bit should be in the same place.

Very clever, I'd never have though of it. :alright:
Posted on 2001-11-26 09:28:44 by Eóin
Why load it into EAX first though? You can operate directly on it
in memory...
Posted on 2001-11-26 10:03:26 by f0dder
didn't know that you could 'and' directly on memory variables.
Posted on 2001-11-26 11:05:15 by dxantos