; carry correction stuff
cmp ecx,edx
setb dl
and edx,1
; stuff-in high_long result
mov dword ptr ds:[eax],ecx
; migrate carry to next loop
add dword ptr ss:[ebp-4],edx ; update cy
loop_check:
add dword ptr ss:[ebp-8],-4 ; bump back pin
mov ecx,dword ptr ss:[ebp+8] ; number of longs
add dword ptr ss:[ebp+8],-1 ; dec number of longs
test ecx,ecx
jnz loop_start ; continue
pop esi
pop ebx
pop ecx
pop ecx
pop ebp
retn
}
}
/*
* let's see a sample with two longs in input: it will give 4 longs
* in output
*/
#define LONGS 2
void
main(void)
{
// the new values will be added to the old ones! so clear them
unsigned out[2*LONGS] = { 0 };
unsigned in[LONGS] = { 0x12345678, 0x87654321 }; // for example...
int i;
unsigned hi, lo;
// note that we here invert the loop direction without problems
// (neither if both inputs longs are 0xFFFFFFFF)
printf("power-of-two alternate method: ");
for (i=0; i<LONGS; i++) {
hi = in[i]; // could'n avoid this extra step
__asm mov eax, hi;
__asm mul eax;
__asm mov hi, edx;
__asm mov lo, eax;
printf("%08x %08x ", hi, lo);
}
printf("\n");
}
他说这个算法是个64位数的2次方运算...