PDA

Click to See Complete Forum and Search --> : [2.0] [C#]CDQ - Convert Double to Quad (386+)?


high6
Oct 23rd, 2007, 02:54 PM
I am wondering how exactly CDQ would work in C#. Anyone know a C# equivalent?

jmcilhinney
Oct 23rd, 2007, 10:37 PM
What does a processor instruction have to do with a high-level language like C#?

wossname
Nov 3rd, 2007, 07:40 AM
Something like this...

ulong CDQ(uint d)
{
if((d & 0x80000000) != 0)
return 0xffffffff00000000 | (ulong)d; //sign extend 1
else
return (ulong)d; //sign extend 0 (this is implicit)
}

In fact since C# is so much higher-level than ASM, the above would be virtually identical to the implementation of the MOVSE (move with sign extend) opcode.