unsigned long sum=0,upperlim=1,n=17;
/*
void test(unsigned long row, unsigned long ld, unsigned long rd)
{//row eax, ld ebx, rd edx, pos ecx, p edi, upperlim ebp
if(row!=upperlim)
{
long pos=upperlim&(~(row|ld|rd));
long p;
while(pos)
{
p=pos&(-pos);
pos-=p;
test(row+p,(ld+p)<<1,(rd+p)>>1);
}
}
else sum++;
}
*/
int main(int argc,char *argv[])
{
time_t tm;
int if2n;
__asm
{
mov esi, upperlim ; upperlim
mov ecx, n
shl esi, cl
add esp, 8
sub esi, 1
mov upperlim, esi ; upperlim
; 71 :
; 72 :
; 73 : test(0, 0, 0);
je SHORT $LN11_main
test esi, esi
je SHORT $LN8_main
lea ecx,[ecx]
$LL10_main:
mov ecx, esi
neg ecx
and ecx, esi
mov eax, ecx
sar eax, 1
push eax
lea edx, DWORD PTR [ecx+ecx]
sub esi, ecx
call _test_ ; test
jmp $LN10_main
_test_:
; _row$ = ecx
; _ld$ = edx
; _rd$ = 8 ; size = 4
; 12 : if (row != upperlim)
mov eax, DWORD PTR upperlim ; upperlim
push ebx
push edi
mov edi, ecx
cmp edi, eax
mov ebx, edx
je SHORT $LN4_test
push ebp
mov ebp, DWORD PTR 8[esp+8]
push esi
mov esi, edi
or esi, ebx
or esi, ebp
not esi
and esi, eax
je SHORT $LN9_test
$LL3_test:
mov eax, esi
neg eax
and eax, esi
lea ecx, DWORD PTR [eax+ebp]
sar ecx, 1
lea edx, DWORD PTR [eax+ebx]
push ecx
add edx, edx
lea ecx, DWORD PTR [eax+edi]
sub esi, eax
call _test_ ; test
test esi, esi
jne SHORT $LL3_test
$LN9_test:
pop esi
pop ebp
pop edi
pop ebx
ret 4
$LN4_test:
add DWORD PTR sum, 1 ; sum
pop edi
pop ebx
ret 4
$LN10_main:
test esi, esi
jne SHORT $LL10_main
jmp SHORT $LN8_main
$LN11_main:
add DWORD PTR sum, 1 ; sum
$LN8_main:
}
printf("共有%ld种排列, 计算时间%d秒 \n", sum, (int) (time(0) - tm));
}