[ODE] building 64bit ODE?

Tanguy Fautre tanguy.fautre at spaceapplications.com
Fri Oct 19 08:49:41 MST 2007


Krystian Ligenza wrote:
> Tanguy Fautre pisze:
>> Krystian Ligenza wrote:
>>> I have tried to build a 64bit version of ODE, but get lots of errors 
>>> from opcode:
>>> error C4235: nonstandard extension used : '__asm' keyword not 
>>> supported on this architecture    \opcode\Ice\IceFPU.h    47

Ok, I've looked at the IceFPU.h file. Here is the faulty part:

//! Fast square root for floating-point values.
inline_ float FastSqrt(float square)
{
#ifdef _MSC_VER
	float retval;

	__asm {
		mov             eax, square
		sub             eax, 0x3F800000
		sar             eax, 1
		add             eax, 0x3F800000
		mov             [retval], eax
	}
	return retval;
#else
	return sqrt(square);
#endif
}


It strikes me that the asm version has no reason not to be in C++.
Without testing, I would say it is the same as the following (note the 
use of a union instead of pointers/casts to solve aliasing issues).

union
{
	float fSquare;
	int32_t iSquare;
} v;

v.fSquare = square;
v.iSquare -= 0x3F800000
v.iSquare >>= 1
v.iSquare += 0x3F800000

return v.fSquare;


Can anyone else check that this is correct ? If it is, I also see no 
reason to have two different versions (one using sqrt() and the 
optimized version), shouldn't we just keep the C++ optimized version ?


Tanguy




More information about the ODE mailing list