Rev 1671 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1671 | mario79 | 1 | ;* Call: *************************************************************** |
2 | lzma_decompress: |
||
3 | push esi |
||
4 | push edi |
||
5 | push ebx |
||
6 | push ebp |
||
1681 | mario79 | 7 | mov esi,[esp+20] |
1671 | mario79 | 8 | xor ebp,ebp |
1681 | mario79 | 9 | mov edi,unpack.code_ |
1671 | mario79 | 10 | inc esi |
11 | lodsd |
||
12 | bswap eax |
||
13 | stosd |
||
14 | xor eax,eax |
||
15 | dec eax |
||
16 | stosd |
||
17 | stosd |
||
18 | stosd |
||
19 | stosd |
||
20 | xchg esi,eax |
||
21 | stosd |
||
22 | mov ecx,0x1F36 |
||
1681 | mario79 | 23 | mov eax,1024 |
24 | mov edi,unpack.p |
||
1671 | mario79 | 25 | rep stosd |
1681 | mario79 | 26 | mov edi,[esp+24] |
1671 | mario79 | 27 | mov ebx, edi |
1681 | mario79 | 28 | add ebx,[esp+28] |
1671 | mario79 | 29 | ;-------------------------------------------------------------------- |
1681 | mario79 | 30 | .main_loop: |
1671 | mario79 | 31 | cmp edi,ebx |
1681 | mario79 | 32 | jnb .main_loop_done |
33 | |||
1671 | mario79 | 34 | mov edx,edi |
35 | and edx,3 |
||
36 | push eax |
||
37 | mov eax,ebp |
||
38 | shl eax,6 |
||
1681 | mario79 | 39 | lea eax,[eax+edx*4+unpack.p] |
40 | call RangeDecoderBitDecode |
||
1671 | mario79 | 41 | pop eax |
42 | jb .labl_06 |
||
1681 | mario79 | 43 | |
1671 | mario79 | 44 | movzx eax,al |
45 | shr eax,5 |
||
1681 | mario79 | 46 | imul eax,eax,3072 |
47 | add eax,unpack.p+0x1CD8 |
||
1671 | mario79 | 48 | mov cl,1 |
49 | cmp ebp,7 |
||
50 | jb .labl_02 |
||
1681 | mario79 | 51 | |
1671 | mario79 | 52 | mov dl,[edi+esi] |
53 | ;-------------------------------------------------------------------- |
||
54 | .labl_01: |
||
55 | add dl,dl |
||
56 | setb ch |
||
57 | push eax |
||
1681 | mario79 | 58 | lea eax,[eax+ecx*4+1024] |
59 | call RangeDecoderBitDecode |
||
1671 | mario79 | 60 | pop eax |
61 | adc cl,cl |
||
62 | jb .labl_03 |
||
1681 | mario79 | 63 | |
1671 | mario79 | 64 | xor ch,cl |
65 | test ch,1 |
||
66 | mov ch,0 |
||
67 | je .labl_01 |
||
68 | ;-------------------------------------------------------------------- |
||
69 | .labl_02: |
||
70 | push eax |
||
71 | lea eax,[eax+ecx*4] |
||
1681 | mario79 | 72 | call RangeDecoderBitDecode |
1671 | mario79 | 73 | pop eax |
74 | adc cl,cl |
||
75 | jnb .labl_02 |
||
76 | ;-------------------------------------------------------------------- |
||
77 | .labl_03: |
||
78 | mov eax,ebp |
||
79 | cmp al,4 |
||
80 | jb .labl_04 |
||
1681 | mario79 | 81 | |
82 | cmp al,10 |
||
1671 | mario79 | 83 | mov al,3 |
84 | jb .labl_04 |
||
1681 | mario79 | 85 | |
1671 | mario79 | 86 | mov al,6 |
87 | ;-------------------------------------------------------------------- |
||
88 | .labl_04: |
||
89 | sub ebp,eax |
||
90 | xchg ecx,eax |
||
91 | ;-------------------------------------------------------------------- |
||
1681 | mario79 | 92 | .main_loop_1: |
1671 | mario79 | 93 | stosb |
1681 | mario79 | 94 | jmp .main_loop |
1671 | mario79 | 95 | ;-------------------------------------------------------------------- |
96 | .labl_06: |
||
1681 | mario79 | 97 | lea eax,[unpack.p+768+ebp*4] |
98 | call RangeDecoderBitDecode |
||
1671 | mario79 | 99 | jnb .labl_09 |
1681 | mario79 | 100 | |
101 | add eax,48 |
||
102 | call RangeDecoderBitDecode |
||
1671 | mario79 | 103 | jb .labl_07 |
1681 | mario79 | 104 | |
1671 | mario79 | 105 | mov eax, ebp |
106 | shl eax,6 |
||
1681 | mario79 | 107 | lea eax,[eax+edx*4+unpack.p+0x3C0] |
108 | call RangeDecoderBitDecode |
||
1671 | mario79 | 109 | jb .labl_08 |
1681 | mario79 | 110 | |
1671 | mario79 | 111 | cmp ebp,7 |
112 | sbb ebp,ebp |
||
1681 | mario79 | 113 | lea ebp,[ebp+ebp+11] |
1671 | mario79 | 114 | mov al,[edi+esi] |
1681 | mario79 | 115 | jmp .main_loop_1 |
1671 | mario79 | 116 | ;-------------------------------------------------------------------- |
117 | .labl_07: |
||
1681 | mario79 | 118 | add eax,48 |
119 | call RangeDecoderBitDecode |
||
120 | xchg esi,[unpack.rep0] |
||
1671 | mario79 | 121 | jnb .labl_08 |
1681 | mario79 | 122 | |
123 | add eax,48 |
||
124 | call RangeDecoderBitDecode |
||
125 | xchg esi,[unpack.rep1] |
||
1671 | mario79 | 126 | jnb .labl_08 |
1681 | mario79 | 127 | |
128 | xchg esi,[unpack.rep2] |
||
1671 | mario79 | 129 | ;-------------------------------------------------------------------- |
130 | .labl_08: |
||
1681 | mario79 | 131 | mov eax,unpack.p+0x14D0 |
132 | call LzmaLenDecode |
||
1671 | mario79 | 133 | push 8 |
134 | jmp .labl_17 |
||
135 | ;-------------------------------------------------------------------- |
||
136 | .labl_09: |
||
1681 | mario79 | 137 | xchg esi,[unpack.rep0] |
138 | xchg esi,[unpack.rep1] |
||
139 | mov [unpack.rep2],esi |
||
140 | mov eax,unpack.p+0xCC8 |
||
141 | call LzmaLenDecode |
||
1671 | mario79 | 142 | push 3 |
143 | pop eax |
||
144 | cmp eax,ecx |
||
145 | jb .labl_10 |
||
1681 | mario79 | 146 | |
1671 | mario79 | 147 | mov eax,ecx |
148 | ;-------------------------------------------------------------------- |
||
149 | .labl_10: |
||
150 | push ecx |
||
151 | push 6 |
||
152 | pop ecx |
||
153 | shl eax,cl |
||
154 | shl eax,2 |
||
1681 | mario79 | 155 | add eax,unpack.p+0x6C0 |
156 | call RangeDecoderBitTreeDecode |
||
1671 | mario79 | 157 | mov esi,ecx |
158 | cmp ecx,4 |
||
159 | jb .labl_16 |
||
1681 | mario79 | 160 | |
1671 | mario79 | 161 | push ecx |
162 | xor eax,eax |
||
163 | inc eax |
||
164 | shr ecx,1 |
||
165 | adc al,al |
||
166 | dec ecx |
||
167 | shl eax,cl |
||
168 | mov esi, eax |
||
169 | pop edx |
||
1681 | mario79 | 170 | cmp edx,14 |
1671 | mario79 | 171 | jnb .labl_11 |
1681 | mario79 | 172 | |
1671 | mario79 | 173 | sub eax,edx |
174 | shl eax,2 |
||
1681 | mario79 | 175 | add eax,unpack.p+0xABC |
1671 | mario79 | 176 | jmp .labl_14 |
177 | ;-------------------------------------------------------------------- |
||
178 | .labl_11: |
||
179 | sub ecx,4 |
||
180 | xor eax,eax |
||
181 | ;-------------------------------------------------------------------- |
||
182 | .labl_12: |
||
1681 | mario79 | 183 | shr dword [unpack.range],1 |
1671 | mario79 | 184 | add eax, eax |
1681 | mario79 | 185 | mov edx,[unpack.code_] |
186 | sub edx,[unpack.range] |
||
1671 | mario79 | 187 | jb .labl_13 |
1681 | mario79 | 188 | |
189 | mov [unpack.code_],edx |
||
1671 | mario79 | 190 | inc eax |
191 | ;-------------------------------------------------------------------- |
||
192 | .labl_13: |
||
1681 | mario79 | 193 | call RangeDecoderBitDecode_1 |
1671 | mario79 | 194 | loop .labl_12 |
195 | mov cl,4 |
||
196 | shl eax,cl |
||
197 | add esi,eax |
||
1681 | mario79 | 198 | mov eax,unpack.p+0xC88 |
1671 | mario79 | 199 | ;-------------------------------------------------------------------- |
200 | .labl_14: |
||
201 | push edi |
||
202 | push ecx |
||
203 | xor edx,edx |
||
204 | inc edx |
||
205 | xor edi,edi |
||
206 | ;-------------------------------------------------------------------- |
||
207 | .labl_15: |
||
208 | push eax |
||
209 | lea eax,[eax+edx*4] |
||
1681 | mario79 | 210 | call RangeDecoderBitDecode |
1671 | mario79 | 211 | lahf |
212 | adc edx,edx |
||
213 | sahf |
||
214 | rcr edi,1 |
||
215 | pop eax |
||
216 | loop .labl_15 |
||
217 | pop ecx |
||
218 | rol edi,cl |
||
219 | add esi,edi |
||
220 | pop edi |
||
221 | ;-------------------------------------------------------------------- |
||
222 | .labl_16: |
||
223 | pop ecx |
||
224 | not esi |
||
225 | push 7 |
||
226 | ;-------------------------------------------------------------------- |
||
227 | .labl_17: |
||
228 | cmp ebp,7 |
||
229 | pop ebp |
||
230 | jb .labl_18 |
||
1681 | mario79 | 231 | |
1671 | mario79 | 232 | inc ebp |
233 | inc ebp |
||
234 | inc ebp |
||
235 | ;-------------------------------------------------------------------- |
||
236 | .labl_18: |
||
237 | inc ecx |
||
238 | push esi |
||
239 | add esi,edi |
||
240 | rep movsb |
||
241 | lodsb |
||
242 | pop esi |
||
1681 | mario79 | 243 | jmp .main_loop_1 |
1671 | mario79 | 244 | ;-------------------------------------------------------------------- |
1681 | mario79 | 245 | .main_loop_done: |
1671 | mario79 | 246 | pop ebp |
247 | pop ebx |
||
248 | pop edi |
||
249 | pop esi |
||
1681 | mario79 | 250 | ret 12 |
1671 | mario79 | 251 | ;***************************************************************************** |
252 | |||
253 | ;* Call: *************************************************************** |
||
1681 | mario79 | 254 | RangeDecoderBitDecode: |
255 | ; in: eax->prob |
||
256 | ; out: CF=bit; destroys eax |
||
1671 | mario79 | 257 | push edx |
1681 | mario79 | 258 | mov edx,[unpack.range] |
259 | shr edx,11 |
||
1671 | mario79 | 260 | imul edx,[eax] |
1681 | mario79 | 261 | cmp [unpack.code_],edx |
262 | jnb .2 |
||
263 | |||
264 | mov [unpack.range],edx |
||
265 | mov edx,2048 |
||
1671 | mario79 | 266 | sub edx,[eax] |
267 | shr edx,5 |
||
268 | add [eax],edx |
||
269 | ;-------------------------------------------------------------------- |
||
1681 | mario79 | 270 | .1: |
1671 | mario79 | 271 | pushfd |
1681 | mario79 | 272 | call RangeDecoderBitDecode_1 |
1671 | mario79 | 273 | popfd |
274 | pop edx |
||
275 | ret |
||
276 | ;-------------------------------------------------------------------- |
||
1681 | mario79 | 277 | .2: |
278 | sub [unpack.range],edx |
||
279 | sub [unpack.code_],edx |
||
1671 | mario79 | 280 | mov edx,[eax] |
281 | shr edx,5 |
||
282 | sub [eax],edx |
||
283 | stc |
||
1681 | mario79 | 284 | jmp .1 |
1671 | mario79 | 285 | ;*********************************************************************** |
286 | |||
287 | ;* Call: *************************************************************** |
||
1681 | mario79 | 288 | RangeDecoderBitDecode_1: |
289 | cmp byte [unpack.range+3],0 |
||
290 | jne @f |
||
291 | |||
292 | shl dword [unpack.range],8 |
||
293 | shl dword [unpack.code_],8 |
||
1671 | mario79 | 294 | push eax |
1681 | mario79 | 295 | mov eax,[unpack.rep3] |
1671 | mario79 | 296 | mov al,[eax] |
1681 | mario79 | 297 | inc dword [unpack.rep3] |
298 | mov [unpack.code_],al |
||
1671 | mario79 | 299 | pop eax |
300 | ;-------------------------------------------------------------------- |
||
1681 | mario79 | 301 | @@: |
1671 | mario79 | 302 | ret |
303 | ;*********************************************************************** |
||
304 | |||
305 | ;* Call: *************************************************************** |
||
1681 | mario79 | 306 | LzmaLenDecode: |
307 | ; in: eax->prob, edx=posState |
||
308 | ; out: ecx=len |
||
309 | call RangeDecoderBitDecode |
||
310 | jnb .2 |
||
311 | |||
1671 | mario79 | 312 | add eax,4 |
1681 | mario79 | 313 | call RangeDecoderBitDecode |
314 | jb .1 |
||
315 | |||
1671 | mario79 | 316 | mov cl,3 |
317 | shl edx,cl |
||
1681 | mario79 | 318 | lea eax,[eax+edx*4+516] |
319 | call RangeDecoderBitTreeDecode |
||
1671 | mario79 | 320 | add ecx,8 |
321 | ret |
||
322 | ;-------------------------------------------------------------------- |
||
1681 | mario79 | 323 | .1: |
324 | add eax,1028 |
||
1671 | mario79 | 325 | mov cl,8 |
1681 | mario79 | 326 | call RangeDecoderBitTreeDecode |
327 | add ecx,16 |
||
1671 | mario79 | 328 | ret |
329 | ;-------------------------------------------------------------------- |
||
1681 | mario79 | 330 | .2: |
1671 | mario79 | 331 | mov cl,3 |
332 | shl edx,cl |
||
333 | lea eax,[eax+edx*4+8] |
||
334 | ;*********************************************************************** |
||
335 | |||
336 | ;* Call: *************************************************************** |
||
1681 | mario79 | 337 | RangeDecoderBitTreeDecode: |
338 | ; in: eax->probs,ecx=numLevels |
||
339 | ; out: ecx=length; destroys edx |
||
1671 | mario79 | 340 | push edi |
341 | xor edx,edx |
||
342 | inc edx |
||
343 | mov edi,edx |
||
344 | xchg edi, eax |
||
345 | ;-------------------------------------------------------------------- |
||
1681 | mario79 | 346 | @@: |
1671 | mario79 | 347 | push eax |
348 | lea eax,[edi+edx*4] |
||
1681 | mario79 | 349 | call RangeDecoderBitDecode |
1671 | mario79 | 350 | pop eax |
351 | adc dl,dl |
||
352 | add al,al |
||
1681 | mario79 | 353 | loop @b |
1671 | mario79 | 354 | sub dl,al |
355 | pop edi |
||
356 | mov ecx,edx |
||
357 | ret |
||
358 | ;*********************************************************************** |
||
359 |