Originally posted by Starless
If you don't like fild in this example, you can do this

mov eax,[esp]
and eax,80000000h
or eax,3f800000h
mov [esp],eax
fld dword ptr [esp]

and much larger than the previous one. :)
This does not work for zero.
Posted on 2003-09-11 17:49:18 by bitRAKE
The code fragment assumes that +-0.0 has been handled by ftst. It was meant to replace the sequence 'fld st/fabs/fdiv'. (And, I omitted push/pop to prepare memory only because I was lazy. :) )
Posted on 2003-09-12 08:03:53 by Starless

mov eax,floatvalue
shl eax,1 ;or add eax,eax
setnz al ;if whatever left is not zero set al to 1
sbb edx,edx ;use carry from shift to get -1 or zero
and eax,1 ;cause setcc only sets the low byte
xor eax,edx ;if carry flag was set, neg value in eax. Of course -0 = 0 for ints
sub eax,edx
Posted on 2003-09-12 14:50:50 by chorus