📄 cl1_d32.s
字号:
/*; cl1_d32.ash -- cl1_decompress_le32 in 32-bit assembly; schema from ucl/nrv2b_d32.ash;; Copyright (C) 2004-2007 John Reiser; Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer; All Rights Reserved.;; This file is free software; you can redistribute it and/or; modify it under the terms of the GNU General Public License as; published by the Free Software Foundation; either version 2 of; the License, or (at your option) any later version.;; This file is distributed in the hope that it will be useful,; but WITHOUT ANY WARRANTY; without even the implied warranty of; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the; GNU General Public License for more details.;; You should have received a copy of the GNU General Public License; along with the UCL library; see the file COPYING.; If not, write to the Free Software Foundation, Inc.,; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.;; Markus F.X.J. Oberhumer John Reiser; <markus@oberhumer.com> <jreiser@BitWagon.com>;; ------------- DECOMPRESSION -------------; Input:; esi - source; edi - dest; ebp - -1; cld; Output:; eax - 0; ecx - 0*/// One of these two is instantiated many times by buildLoadersection CL1SMA1B call edxsection CL1FAS1B add ebx, ebx jnzs 1f call edx1:section CL1GET1Bsection CL1ENTER nop // 'int3' for debugging call start_cl1 // pic push address of next instrsection CL1SMA10getbit_cl1: // appears only in small version add ebx, ebx jzs reload_cl1 retsection CL1RLOADreload_cl1: // for both small and fast version mov ebx, [esi] sub esi, -4 adc ebx, ebx retsection CL1WID01widelit_cl1: sub ecx,ecx // back to 0 // getbitsection CL1WID02 adc ecx,ecx // getbitsection CL1WID03 jcs lit89_cl1 // getbitsection CL1WID04 adc ecx,ecx // getbitsection CL1WID05 jcs lit10_12_cl1 // getbitsection CL1WID06 adc ecx,ecx // 0..7; -1+ (width/2) of lengthlitwidth_cl1: // ss22 algorithm, counted width<=8 pairs; returns eax= 2..0x15555 // getbitsection CL1WID07 adc eax,eax dec eax // getbitsection CL1WID08 adc eax,eax sub ecx, 1 jncs litwidth_cl1 lea ecx,[17 -2 + eax] // 17: predecessors; ss22 returns 2.. cmp eax,0xffff-(17 -2) jbs litgo_cl1 // not maximal range of search lea eax,[esi + ecx] // esi after copy push eax // "parameter" to maxlit_cl1 jmp maxlit_cl1 // can have another literal afterwardslit13_16_cl1: // getbitsection CL1WID09 adc ecx,ecx // getbitsection CL1WID10 adc ecx,ecx add ecx, 13 jmps litmov_cl1lit10_12_cl1: test ecx,ecx jzs lit13_16_cl1 inc ecx // 2,3,4lit89_cl1: add ecx, 8litgo_cl1: jmps litmov_cl1section CL1STARTstart_cl1: sub ecx,ecx // 0 pop edx // edx= getbit_cl1 or reload_cl1 sub ebx, ebx // cause reload on first bitsection CL1TOP00top_cl1: // In: 0==ecx lea eax,[1+ ecx] // 1: the msb of offset or large width // getbitsection CL1TOP01 jncs match_cl1 // getbitsection CL1TOP02 jcs lit1_cl1 // getbitsection CL1TOP03 jcs lit2_cl1 // getbitsection CL1TOP04 jcs lit3_cl1 add ecx, 2 // getbitsection CL1TOP05 jcs lit45_cl1 inc ecx // getbitsection CL1TOP06 jcs lit67_cl1 jmp widelit_cl1lit67_cl1:lit45_cl1: // getbitsection CL1TOP07 adc ecx,ecxlitmov_cl1: .byte 0xD1,((3<<6)|(5<<3)|1) //shr ecx,1 jncs litmovb_cl1 movsblitmovb_cl1: .byte 0xD1,((3<<6)|(5<<3)|1) //shr ecx,1 jncs litmovw_cl1 movswlitmovw_cl1: rep movsd lea eax,[1+ ecx] // 1: the msb jmps litdone_cl1lit3_cl1: movsblit2_cl1: movsblit1_cl1: movsblitdone_cl1:match_cl1: // In: 0==ecx; 1==eaxoffset_cl1: // ss11 algorithm // getbitsection CL1OFF01 adc eax,eax // getbitsection CL1OFF02 jncs offset_cl1 sub eax, 3 // 2.. ==> -1[prev], (0,,<<8)|byte jcs prev_off_cl1 shl eax,8 lodsb xor eax, ~0 jzs done_cl1 // EOF mov ebp,eax // -offsetprev_off_cl1: // 1st 2 bits encode (5<=len),2,3,4 // getbitsection CL1OFF03 adc ecx,ecx // getbitsection CL1OFF04 adc ecx,ecx jnzs wrinkle_cl1section CL1LEN00 inc ecx // 1: the msbmlen_cl1: // getbitsection CL1LEN01 adc ecx,ecx // getbitsection CL1LEN02 jncs mlen_cl1 add ecx, 2 // 2.. ==> 4..section CL1COPY0wrinkle_cl1: cmp ebp,-0xd00 adc ecx, 1copy_cl1: push esi lea esi,[edi + ebp] cmp ebp, -4 ja ripple_cl1maxlit_cl1: // literal copy cannot overlap; omit test for ripple .byte 0xD1,((3<<6)|(5<<3)|1) //shr ecx,1 jncs maxlitb_cl1 movsbmaxlitb_cl1: .byte 0xD1,((3<<6)|(5<<3)|1) //shr ecx,1 jncs maxlitw_cl1 movswmaxlitw_cl1: rep movsdpopbot_cl1: pop esibottom_cl1: jmp top_cl1ripple_cl1: cmp ebp, -1 jne ripmov_cl1 lodsb rep stosb jmps popbot_cl1ripmov_cl1: rep movsb jmps popbot_cl1done_cl1:section CL1END// vi:ts=8:et
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -