Subversion Repositories Kolibri OS

Rev

Rev 1671 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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