C
Clive Tooth
Here is some code that I would like to speed up...
=================================
unchecked
{
for (int i = startI; i < stopI; i++)
{
uint m = (a << 8) | carry;
carry = m/myBase;
if ((a = m%myBase) == 0)
{
WorkerFoundZero(myNumber, i);
}
} // i loop
} // unchecked
=================================
a[], carry, myBase are uints. It seems that I need to do *two* divide
instructions "m/myBase" and "m%myBase". Of course, the processor has a
DIV instruction that returns both the quotient and the remainder. How
can I get access to both results? Math.DivRem does not seem
particularly fast, also it only accepts int and long operands.
Ideally, I would like to be able to write a couple of lines of
assembler in my c# program.
=================================
unchecked
{
for (int i = startI; i < stopI; i++)
{
uint m = (a << 8) | carry;
carry = m/myBase;
if ((a = m%myBase) == 0)
{
WorkerFoundZero(myNumber, i);
}
} // i loop
} // unchecked
=================================
a[], carry, myBase are uints. It seems that I need to do *two* divide
instructions "m/myBase" and "m%myBase". Of course, the processor has a
DIV instruction that returns both the quotient and the remainder. How
can I get access to both results? Math.DivRem does not seem
particularly fast, also it only accepts int and long operands.
Ideally, I would like to be able to write a couple of lines of
assembler in my c# program.