123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478 |
- NbStack equ 76
- cur_match equ dword ptr[esp+NbStack-0]
- str_s equ dword ptr[esp+NbStack-4]
- adrret equ dword ptr[esp+NbStack-8]
- pushebp equ dword ptr[esp+NbStack-12]
- pushedi equ dword ptr[esp+NbStack-16]
- pushesi equ dword ptr[esp+NbStack-20]
- pushebx equ dword ptr[esp+NbStack-24]
- chain_length equ dword ptr [esp+NbStack-28]
- limit equ dword ptr [esp+NbStack-32]
- best_len equ dword ptr [esp+NbStack-36]
- window equ dword ptr [esp+NbStack-40]
- prev equ dword ptr [esp+NbStack-44]
- scan_start equ word ptr [esp+NbStack-48]
- wmask equ dword ptr [esp+NbStack-52]
- match_start_ptr equ dword ptr [esp+NbStack-56]
- nice_match equ dword ptr [esp+NbStack-60]
- scan equ dword ptr [esp+NbStack-64]
- windowlen equ dword ptr [esp+NbStack-68]
- match_start equ dword ptr [esp+NbStack-72]
- strend equ dword ptr [esp+NbStack-76]
- NbStackAdd equ (NbStack-24)
- .386p
- name gvmatch
- .MODEL FLAT
- zlib1222add equ 8
- dep_chain_length equ 74h+zlib1222add
- dep_window equ 30h+zlib1222add
- dep_strstart equ 64h+zlib1222add
- dep_prev_length equ 70h+zlib1222add
- dep_nice_match equ 88h+zlib1222add
- dep_w_size equ 24h+zlib1222add
- dep_prev equ 38h+zlib1222add
- dep_w_mask equ 2ch+zlib1222add
- dep_good_match equ 84h+zlib1222add
- dep_match_start equ 68h+zlib1222add
- dep_lookahead equ 6ch+zlib1222add
- _TEXT segment
- IFDEF NOUNDERLINE
- public longest_match
- public match_init
- ELSE
- public _longest_match
- public _match_init
- ENDIF
- MAX_MATCH equ 258
- MIN_MATCH equ 3
- MIN_LOOKAHEAD equ (MAX_MATCH+MIN_MATCH+1)
- MAX_MATCH equ 258
- MIN_MATCH equ 3
- MIN_LOOKAHEAD equ (MAX_MATCH + MIN_MATCH + 1)
- MAX_MATCH_8_ equ ((MAX_MATCH + 7) AND 0FFF0h)
- chainlenwmask equ esp + 0
-
- window equ esp + 4
- windowbestlen equ esp + 8
- scanstart equ esp + 16
- scanend equ esp + 12
- scanalign equ esp + 20
- nicematch equ esp + 24
- bestlen equ esp + 28
- scan equ esp + 32
- LocalVarsSize equ 36
- deflatestate equ esp + 56
- curmatch equ esp + 60
- dsWSize equ 36+zlib1222add
- dsWMask equ 44+zlib1222add
- dsWindow equ 48+zlib1222add
- dsPrev equ 56+zlib1222add
- dsMatchLen equ 88+zlib1222add
- dsPrevMatch equ 92+zlib1222add
- dsStrStart equ 100+zlib1222add
- dsMatchStart equ 104+zlib1222add
- dsLookahead equ 108+zlib1222add
- dsPrevLen equ 112+zlib1222add
- dsMaxChainLen equ 116+zlib1222add
- dsGoodMatch equ 132+zlib1222add
- dsNiceMatch equ 136+zlib1222add
- IFDEF NOUNDERLINE
- longest_match proc near
- ELSE
- _longest_match proc near
- ENDIF
- push ebp
- push edi
- push esi
- push ebx
- sub esp, LocalVarsSize
- mov edx, [deflatestate]
- mov ecx, [curmatch]
- mov eax, [edx + dsPrevLen]
- mov ebx, [edx + dsGoodMatch]
- cmp eax, ebx
- mov eax, [edx + dsWMask]
- mov ebx, [edx + dsMaxChainLen]
- jl LastMatchGood
- shr ebx, 2
- LastMatchGood:
- dec ebx
- shl ebx, 16
- or ebx, eax
- mov [chainlenwmask], ebx
- mov eax, [edx + dsNiceMatch]
- mov ebx, [edx + dsLookahead]
- cmp ebx, eax
- jl LookaheadLess
- mov ebx, eax
- LookaheadLess: mov [nicematch], ebx
- mov esi, [edx + dsWindow]
- mov [window], esi
- mov ebp, [edx + dsStrStart]
- lea edi, [esi + ebp]
- mov [scan], edi
- mov eax, edi
- neg eax
- and eax, 3
- mov [scanalign], eax
- mov eax, [edx + dsWSize]
- sub eax, MIN_LOOKAHEAD
- sub ebp, eax
- jg LimitPositive
- xor ebp, ebp
- LimitPositive:
- mov eax, [edx + dsPrevLen]
- mov [bestlen], eax
- add esi, eax
- mov [windowbestlen], esi
- movzx ebx, word ptr [edi]
- mov [scanstart], ebx
- movzx ebx, word ptr [edi + eax - 1]
- mov [scanend], ebx
- mov edi, [edx + dsPrev]
- mov edx, [chainlenwmask]
- jmp short LoopEntry
- align 4
- LookupLoop:
- and ecx, edx
- movzx ecx, word ptr [edi + ecx*2]
- cmp ecx, ebp
- jbe LeaveNow
- sub edx, 00010000h
- js LeaveNow
- LoopEntry: movzx eax, word ptr [esi + ecx - 1]
- cmp eax, ebx
- jnz LookupLoop
- mov eax, [window]
- movzx eax, word ptr [eax + ecx]
- cmp eax, [scanstart]
- jnz LookupLoop
- mov [chainlenwmask], edx
- mov esi, [window]
- mov edi, [scan]
- add esi, ecx
- mov eax, [scanalign]
- mov edx, 0fffffef8h
- lea edi, [edi + eax + 0108h]
- lea esi, [esi + eax + 0108h]
- LoopCmps:
- mov eax, [esi + edx]
- xor eax, [edi + edx]
- jnz LeaveLoopCmps
- mov eax, [esi + edx + 4]
- xor eax, [edi + edx + 4]
- jnz LeaveLoopCmps4
- add edx, 8
- jnz LoopCmps
- jmp short LenMaximum
- LeaveLoopCmps4: add edx, 4
- LeaveLoopCmps: test eax, 0000FFFFh
- jnz LenLower
- add edx, 2
- shr eax, 16
- LenLower: sub al, 1
- adc edx, 0
- lea eax, [edi + edx]
- mov edi, [scan]
- sub eax, edi
- cmp eax, MAX_MATCH
- jge LenMaximum
- mov edx, [deflatestate]
- mov ebx, [bestlen]
- cmp eax, ebx
- jg LongerMatch
- mov esi, [windowbestlen]
- mov edi, [edx + dsPrev]
- mov ebx, [scanend]
- mov edx, [chainlenwmask]
- jmp LookupLoop
- LongerMatch: mov ebx, [nicematch]
- mov [bestlen], eax
- mov [edx + dsMatchStart], ecx
- cmp eax, ebx
- jge LeaveNow
- mov esi, [window]
- add esi, eax
- mov [windowbestlen], esi
- movzx ebx, word ptr [edi + eax - 1]
- mov edi, [edx + dsPrev]
- mov [scanend], ebx
- mov edx, [chainlenwmask]
- jmp LookupLoop
- LenMaximum: mov edx, [deflatestate]
- mov dword ptr [bestlen], MAX_MATCH
- mov [edx + dsMatchStart], ecx
- LeaveNow:
- mov edx, [deflatestate]
- mov ebx, [bestlen]
- mov eax, [edx + dsLookahead]
- cmp ebx, eax
- jg LookaheadRet
- mov eax, ebx
- LookaheadRet:
- add esp, LocalVarsSize
- pop ebx
- pop esi
- pop edi
- pop ebp
- ret
- db 0dh,0ah,"asm686 with masm, optimised assembly code from Brian Raiter, written 1998",0dh,0ah
- IFDEF NOUNDERLINE
- longest_match endp
- ELSE
- _longest_match endp
- ENDIF
- IFDEF NOUNDERLINE
- match_init proc near
- ret
- match_init endp
- ELSE
- _match_init proc near
- ret
- _match_init endp
- ENDIF
- _TEXT ends
- end
|