Aktív témák

  • P.H.

    senior tag

    Közismert és általános algoritmushoz tartozó kód legalább 6-7 éve és ma

    Első rész, a főciklus előtti inicializációs részek:

    Régen:
    mov ecx,[MTXDBLSIZE]
    mov edi,[MARKS]
    xor eax,eax
    mov ebp,[MTXSIZE]
    mov edx,ecx
    rep stosd
    lea edi,[tempmarks]
    mov ecx,edx
    rep stosd

    @reduce_rows_with_minimum:
    mov edi,[mtx]
    mov edx,ebp
    mov esi,00FFFFFFh
    @row_minimum:
    mov ecx,ebp
    mov ebx,edi
    mov eax,esi
    mov ch,cl
    @find_row_minimum:
    scasd
    jb @after_row_test
    mov eax,[edi-04h]
    @after_row_test:
    dec cl
    jnz @find_row_minimum
    @start_reduce_row:
    test eax,eax
    jnz @force_reduce_row
    dec edx
    jnz @row_minimum
    jmp @reduce_columns_with_minimum
    @force_reduce_row:
    cmp eax,esi
    jz @abnormal_exit
    @reduce_row_elements:
    cmp [ebx],esi
    ja @after_row_reduction
    sub [ebx],eax
    @after_row_reduction:
    add ebx,04h
    dec ch
    jnz @reduce_row_elements
    dec edx
    jnz @row_minimum

    @reduce_columns_with_minimum:
    mov esi,[mtx]
    mov ebx,ebp
    lea edi,[ebp*04h]
    @column_minimum:
    mov ecx,ebp
    mov eax,00FFFFFFh
    mov edx,esi
    mov ch,cl
    @find_column_minimum:
    cmp [esi],eax
    ja @after_column_test
    mov eax,[esi]
    test eax,eax
    jz @next_decrease_column
    @after_column_test:
    add esi,edi
    dec cl
    jnz @find_column_minimum
    @start_reduce_column:
    cmp eax,00FFFFFFh
    jz @abnormal_exit
    mov esi,edx
    @reduce_column_elements:
    cmp dword ptr [esi],00FFFFFFh
    ja @after_column_reduction
    sub [esi],eax
    @after_column_reduction:
    add esi,edi
    dec ch
    jnz @reduce_column_elements
    @next_decrease_column:
    lea esi,[edx+04h]
    dec ebx
    jnz @column_minimum

    @determine_start0_system:
    mov [sys0],ebx
    mov edi,[marks]
    mov ebx,ebp
    mov eax,0102h
    mov esi,[mtx]
    xor ecx,ecx
    dec ebx
    push esi
    xor edx,edx
    @start_0system:
    lea esi,[esi+ebx*04h]
    @find_free0:
    test [edi+edx],al
    jnz @check_next_item
    cmp [esi],ecx
    jnz @check_next_item
    or [edi+edx],al
    or [edi+ebx],ah
    or [esi+03h],ah
    inc [sys0]
    jmp @next_column
    @check_next_item:
    inc edx
    lea esi,[esi+ebp*04h]
    cmp edx,ebp
    jnz @find_free0
    @next_column:
    mov esi,[esp]
    xor edx,edx
    dec ebx
    jns @start_0system
    pop ebx

    cmp ebp,[sys0]
    jz @count_result
    mov eax,01010101h
    mov ecx,[MTXDBLSIZE]
    @clearrowmark:
    and [edi],eax
    sub ecx,01h
    lea edi,[edi+04h]
    jnz @clearrowmark
    pushad
    jmp @@2nd_step

    Mai termés (kb. 10% gyorsulás a teljes lefutásra vetítve)
    mov ebp,[MTXSIZE]
    @reduce_rows_with_minimum:
    mov esi,00FFFFFFh
    mov edi,[MTX]
    mov edx,ebp
    @rowmin:
    mov eax,esi
    mov ebx,edi
    mov ecx,ebp
    @findrowmin:
    cmp eax,[ebx]
    jb @nxrowmin
    mov eax,[ebx]
    @nxrowmin:
    sub ecx,01h
    lea ebx,[ebx+04h]
    jnz @findrowmin
    cmp eax,esi
    mov ecx,ebp
    jz @abnormal_exit
    @decrow:
    cmp [edi],esi
    sbb ebx,ebx
    and ebx,eax
    sub [edi],ebx
    sub ecx,01h
    lea edi,[edi+04h]
    jnz @decrow
    sub edx,01h
    jnz @rowmin

    @reduce_columns_with_minimum:
    mov ebx,ebp
    shl ebp,02h
    mov edi,[MTX]
    @colmin:
    mov ecx,ebp
    mov eax,esi
    @findcolmin:
    cmp [edi],eax
    ja @nxcolmin
    mov eax,[edi]
    @nxcolmin:
    sub ecx,04h
    lea edi,[edi+ebp]
    jnz @findcolmin
    neg ebp
    cmp eax,esi
    mov ecx,ebp
    jz @abnormal_exit
    @deccol:
    add edi,ebp
    cmp [edi],esi
    sbb edx,edx
    and edx,eax
    sub [edi],edx
    add ecx,04h
    jnz @deccol
    neg ebp
    sub ebx,01h
    lea edi,[edi+04h]
    jnz @colmin
    shr ebp,02h

    imul ecx,[MTXDBLSIZE],BYTE(4)
    xor eax,eax
    mov edi,[MARKS]
    mov edx,offset(TEMPMARKS)
    mov esi,[MTX]
    @clrmark:
    sub ecx,04h
    mov [edi+ecx],eax
    mov [edx+ecx],eax
    jg @clrmark

    @determine_start0_system:
    lea ebx,[ebp-01h]
    add eax,01h
    push esi
    @start0system:
    lea esi,[esi+ebx*04h]
    xor edx,edx
    @findfree0:
    cmp dword ptr [esi],00h
    jz @markitem
    @nxrow:
    add edx,eax
    lea esi,[esi+ebp*04h]
    cmp edx,ebp
    jnz @findfree0
    jmp @nxcol
    @markitem:
    bts [edi+edx],eax
    jc @nxrow
    or [edi+ebx],al
    add ecx,eax
    or [esi+03h],al
    @nxcol:
    sub ebx,eax
    mov esi,[esp]
    jns @start0system
    pop ebx
    mov [SYS0],ecx

    cmp ebp,ecx
    mov eax,01010101h
    jz @count_result
    mov ecx,[MTXDBLSIZE]
    @clearrowmark:
    and [edi],eax
    sub ecx,01h
    lea edi,[edi+04h]
    jnz @clearrowmark
    pushad
    jmp @@2nd_step

    [ Szerkesztve ]

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

Aktív témák