Hirdetés

2024. április 25., csütörtök

Gyorskeresés

Hozzászólások

(#27) P.H.


P.H.
senior tag

Algoritmusban felhasználásra kihegyezve (több 100000 lefutás); Shanghai-on 1.4 IPC, ezredmásodpercenként legalább 20 db 25x25-ös mátrix megoldása.

pushad
mov ebx,offset(MARKS)
lea ecx,[ebp+ebp]
xor edx,edx
lea edi,[ebx+ebp]
neg ebp
@mark0:
sub ecx,04h
mov [ebx],edx
lea ebx,[ebx+04h]
jg @mark0
@@REDUCE_ROWS:
mov [esp+__SYS0],ebp
mov ebx,ebp
@rowmin:
mov esi,01000000h
xor edx,edx
mov ecx,ebp
@findrowmin:
cmp esi,[eax]
cmovz edx,ecx
cmova esi,[eax]
add ecx,01h
lea eax,[eax+04h]
jnz @findrowmin
sub ecx,ebp
cmp esi,01000000h
jz @specific
lea eax,[eax+ebp*04h]
@subrow:
xor edx,edx
cmp byte ptr [eax+03h],00h
cmovz edx,esi
sub [eax],edx
sub ecx,01h
lea eax,[eax+04h]
jnz @subrow
jmp @reducenxrow
@specific:
test edx,edx
jz @@ABNORMAL_EXIT
test byte ptr [edi+edx],01h
jz @mark
@@ABNORMAL_EXIT:
add esp,20h
xor eax,eax
mov edx,7FFFFFFFh
stc
ret
@mark:
or byte ptr [edi+ebx],10h
add ecx,ebx
or byte ptr [edi+edx],01h
add dword ptr [esp+__SYS0],01h
mov [edi+ecx],dl
@reducenxrow:
add ebx,01h
jnz @rowmin
@@REDUCE_COLUMNS:
mov ebx,ebp
mov esi,[esp+__MTX]
@colmin:
mov ecx,ebp
xor eax,eax
mov edx,01000000h
neg ebp
@findcolmin:
cmp edx,[esi]
cmovz eax,ecx
cmova edx,[esi]
add ecx,01h
lea esi,[esi+ebp*04h]
jnz @findcolmin
neg ebp
cmp edx,01000000h
mov ecx,ebp
jb @subcol
test eax,eax
jz @@ABNORMAL_EXIT
@subcol:
lea esi,[esi+ebp*04h]
xor eax,eax
cmp byte ptr [esi+03h],00h
cmovz eax,edx
sub [esi],eax
add ecx,01h
jnz @subcol
add ebx,01h
lea esi,[esi+04h]
jnz @colmin
mov eax,00000001h
neg ebp
@@START0_SYSTEM:
xor ecx,ecx
sub esi,04h
sub ebx,eax
sub ecx,ebp
mov edx,esi
@findfree0:
cmp [esi],eax
jb @markitem
@nxrow:
add ecx,eax
lea esi,[esi+ebp*04h]
jnz @findfree0
jmp @nxcol
@markitem:
bts dword ptr [edi+ecx],04h
jc @nxrow
add ecx,ebp
mov [esi+03h],al
add [esp+__SYS0],eax
mov [edi+ecx],bl
or [edi+ebx],al
@nxcol:
lea ecx,[ebx+ebp]
mov esi,edx
test ecx,ecx
jnz @@START0_SYSTEM
cmp [esp+__SYS0],ecx
jz @count_result_MTX
sub esp,_SAVE
jmp @@2ND_STEP
@@3RD_STEP:
mov byte ptr [esi+03h],02h
and byte ptr [edi+edx],11111110b
@@2ND_STEP:
xor ebx,ebx
mov esi,[esp+_SAVE+__MTX]
xor ecx,ecx
mov edx,00FFFFFFh
sub ebx,ebp
@free0:
sub ecx,ebp
@freerow:
test byte ptr [edi+ebx],02h
jz @zeroinrow
add ebx,01h
lea esi,[esi+ebp*04h]
jnz @freerow
jmp @@5TH_STEP
@zeroinrow:
xor eax,eax
test byte ptr [edi+ecx],01h
jnz @nx2col
add eax,[esi]
jz @@DECIDE_NEXT_STEP
cmp edx,eax
cmova edx,eax
jbe @nx2col
add esp,_SAVE
pushad
@nx2col:
add ecx,01h
lea esi,[esi+04h]
jnz @zeroinrow
add ebx,01h
jnz @free0
@@5TH_STEP:
xor ecx,ecx
mov esi,[esp+_SAVE+__MTX]
sub ebx,ebp
@nx5row:
sub ecx,ebp
test byte ptr [edi+ebx],02h
jz @decrease_row_free
@increase_double_markeds:
mov al,[esi+03h]
and al,11111100b
bt dword ptr [edi+ecx],00h
sbb al,00h
sbb eax,eax
and eax,edx
add [esi],eax
add ecx,01h
lea esi,[esi+04h]
jnz @increase_double_markeds
jmp @step5row
@decrease_row_free:
bt dword ptr [edi+ecx],00h
mov al,[esi+03h]
adc al,00h
mov eax,00000000h
cmovz eax,edx
sub [esi],eax
add ecx,01h
lea esi,[esi+04h]
jnz @decrease_row_free
@step5row:
add ebx,01h
jnz @nx5row
popad
sub esp,20h
@@DECIDE_NEXT_STEP:
mov edx,0FFFFFF00h
lea eax,[ebx+ebp]
or byte ptr [edi+ebx],02h
add dl,[edi+eax]
jnz @@3RD_STEP
@@4TH_STEP:
mov edx,[esp+_SAVE+__MTX]
@colon_to_star:
mov [edi+eax],cl
add ecx,ebp
mov byte ptr [esi+03h],01h
xor eax,eax
lea esi,[edx+ecx*04h]
shl ecx,02h
and byte ptr [edi+ebx],11111101b
sub eax,ebp
@search_star_in_column:
test byte ptr [esi+03h],01h
jz @nxstar
cmp eax,ebx
jnz @0_star
@nxstar:
add eax,01h
lea esi,[esi+ebp*04h]
jnz @search_star_in_column
jmp @@1ST_STEP
@0_star:
mov ebx,eax
mov byte ptr [esi+03h],00h
add eax,ebp
sub esi,ecx
xor ecx,ecx
mov byte ptr [edi+eax],00h
sub ecx,ebp
@search_colon_in_row:
test byte ptr [esi+03h],02h
jnz @colon_to_star
add ecx,01h
lea esi,[esi+04h]
jnz @search_colon_in_row
@error:
nop
@@1ST_STEP:
xor ebx,ebx
xor eax,eax
add dword ptr [esp+_SAVE+__SYS0],01h
jz @count_result_STACK
sub ebx,ebp
mov cl,[edi+00h]
jmp @nxclear
@clear_colon:
and byte ptr [esi+03h],11111101b
add eax,01h
lea esi,[esi+04h]
jnz @clear_colon
@nxclear:
sub eax,ebp
@markedrow:
test byte ptr [edi+ebx],02h
mov esi,edx
mov byte ptr [edi+ebx],00h
jnz @clear_colon
add ebx,01h
lea edx,[edx+ebp*04h]
jnz @markedrow
@markcol:
movsx edx,byte ptr [edi+ebx]
add ebx,01h
add eax,01h
mov byte ptr [edi+edx],01h
jnz @markcol
mov [edi+00h],cl
jmp @@2ND_STEP
@count_result_STACK:
add esp,_SAVE
@count_result_MTX:
xor ecx,ecx
xor eax,eax
mov esi,[esp+__SAVE]
mov ebx,[esp+__MARKS]
add esp,20h
@results:
movsx edx,byte ptr [edi+ecx]
add ecx,01h
add edx,ebp
add eax,[esi+edx*04h]
cmp ecx,ebp
mov [ebx],dl
lea esi,[esi+ebp*04h]
lea ebx,[ebx+01h]
jnz @results

[ Szerkesztve ]

Arguing on the Internet is like running in the Special Olympics. Even if you win, you are still ... ˙˙˙ Real Eyes Realize Real Lies ˙˙˙

Copyright © 2000-2024 PROHARDVER Informatikai Kft.