Subversion Repositories Kolibri OS

Rev

Rev 1671 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;* Call: ***************************************************************
  2. lzma_decompress:
  3.         push    esi
  4.         push    edi
  5.         push    ebx
  6.         push    ebp
  7.         mov     esi,[esp+20]
  8.         xor     ebp,ebp
  9.         mov     edi,unpack.code_
  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
  23.         mov     eax,1024
  24.         mov     edi,unpack.p
  25.         rep     stosd
  26.         mov     edi,[esp+24]
  27.         mov     ebx, edi
  28.         add     ebx,[esp+28]
  29. ;--------------------------------------------------------------------
  30. .main_loop:
  31.         cmp     edi,ebx
  32.         jnb     .main_loop_done
  33.  
  34.         mov     edx,edi
  35.         and     edx,3
  36.         push    eax
  37.         mov     eax,ebp
  38.         shl     eax,6
  39.         lea     eax,[eax+edx*4+unpack.p]
  40.         call    RangeDecoderBitDecode
  41.         pop     eax
  42.         jb      .labl_06
  43.  
  44.         movzx   eax,al
  45.         shr     eax,5
  46.         imul    eax,eax,3072
  47.         add     eax,unpack.p+0x1CD8
  48.         mov     cl,1
  49.         cmp     ebp,7
  50.         jb      .labl_02
  51.  
  52.         mov     dl,[edi+esi]
  53. ;--------------------------------------------------------------------
  54. .labl_01:
  55.         add     dl,dl
  56.         setb    ch
  57.         push    eax
  58.         lea     eax,[eax+ecx*4+1024]
  59.         call    RangeDecoderBitDecode
  60.         pop     eax
  61.         adc     cl,cl
  62.         jb      .labl_03
  63.  
  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]
  72.         call    RangeDecoderBitDecode
  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
  81.  
  82.         cmp     al,10
  83.         mov     al,3
  84.         jb      .labl_04
  85.  
  86.         mov     al,6
  87. ;--------------------------------------------------------------------
  88. .labl_04:
  89.         sub     ebp,eax
  90.         xchg    ecx,eax
  91. ;--------------------------------------------------------------------
  92. .main_loop_1:
  93.         stosb
  94.         jmp     .main_loop
  95. ;--------------------------------------------------------------------
  96. .labl_06:
  97.         lea     eax,[unpack.p+768+ebp*4]
  98.         call    RangeDecoderBitDecode
  99.         jnb     .labl_09
  100.  
  101.         add     eax,48
  102.         call    RangeDecoderBitDecode
  103.         jb      .labl_07
  104.  
  105.         mov     eax, ebp
  106.         shl     eax,6
  107.         lea     eax,[eax+edx*4+unpack.p+0x3C0]
  108.         call    RangeDecoderBitDecode
  109.         jb      .labl_08
  110.  
  111.         cmp     ebp,7
  112.         sbb     ebp,ebp
  113.         lea     ebp,[ebp+ebp+11]
  114.         mov     al,[edi+esi]
  115.         jmp     .main_loop_1
  116. ;--------------------------------------------------------------------
  117. .labl_07:
  118.         add     eax,48
  119.         call    RangeDecoderBitDecode
  120.         xchg    esi,[unpack.rep0]
  121.         jnb     .labl_08
  122.  
  123.         add     eax,48
  124.         call    RangeDecoderBitDecode
  125.         xchg    esi,[unpack.rep1]
  126.         jnb     .labl_08
  127.  
  128.         xchg    esi,[unpack.rep2]
  129. ;--------------------------------------------------------------------
  130. .labl_08:
  131.         mov     eax,unpack.p+0x14D0
  132.         call    LzmaLenDecode
  133.         push    8
  134.         jmp     .labl_17
  135. ;--------------------------------------------------------------------
  136. .labl_09:
  137.         xchg    esi,[unpack.rep0]
  138.         xchg    esi,[unpack.rep1]
  139.         mov     [unpack.rep2],esi
  140.         mov     eax,unpack.p+0xCC8
  141.         call    LzmaLenDecode
  142.         push    3
  143.         pop     eax
  144.         cmp     eax,ecx
  145.         jb      .labl_10
  146.  
  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
  155.         add     eax,unpack.p+0x6C0
  156.         call    RangeDecoderBitTreeDecode
  157.         mov     esi,ecx
  158.         cmp     ecx,4
  159.         jb      .labl_16
  160.  
  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
  170.         cmp     edx,14
  171.         jnb     .labl_11
  172.  
  173.         sub     eax,edx
  174.         shl     eax,2
  175.         add     eax,unpack.p+0xABC
  176.         jmp     .labl_14
  177. ;--------------------------------------------------------------------
  178. .labl_11:
  179.         sub     ecx,4
  180.         xor     eax,eax
  181. ;--------------------------------------------------------------------
  182. .labl_12:
  183.         shr     dword [unpack.range],1
  184.         add     eax, eax
  185.         mov     edx,[unpack.code_]
  186.         sub     edx,[unpack.range]
  187.         jb      .labl_13
  188.  
  189.         mov     [unpack.code_],edx
  190.         inc     eax
  191. ;--------------------------------------------------------------------
  192. .labl_13:
  193.         call    RangeDecoderBitDecode_1
  194.         loop    .labl_12
  195.         mov     cl,4
  196.         shl     eax,cl
  197.         add     esi,eax
  198.         mov     eax,unpack.p+0xC88
  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]
  210.         call    RangeDecoderBitDecode
  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
  231.  
  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
  243.         jmp     .main_loop_1
  244. ;--------------------------------------------------------------------
  245. .main_loop_done:
  246.         pop     ebp
  247.         pop     ebx
  248.         pop     edi
  249.         pop     esi
  250.         ret     12
  251. ;*****************************************************************************
  252.  
  253. ;* Call: ***************************************************************
  254. RangeDecoderBitDecode:
  255. ; in: eax->prob
  256. ; out: CF=bit; destroys eax
  257.         push    edx
  258.         mov     edx,[unpack.range]
  259.         shr     edx,11
  260.         imul    edx,[eax]
  261.         cmp     [unpack.code_],edx
  262.         jnb     .2
  263.  
  264.         mov     [unpack.range],edx
  265.         mov     edx,2048
  266.         sub     edx,[eax]
  267.         shr     edx,5
  268.         add     [eax],edx
  269. ;--------------------------------------------------------------------
  270. .1:
  271.         pushfd
  272.         call    RangeDecoderBitDecode_1
  273.         popfd
  274.         pop     edx
  275.         ret
  276. ;--------------------------------------------------------------------
  277. .2:
  278.         sub     [unpack.range],edx
  279.         sub     [unpack.code_],edx
  280.         mov     edx,[eax]
  281.         shr     edx,5
  282.         sub     [eax],edx
  283.         stc
  284.         jmp     .1
  285. ;***********************************************************************
  286.  
  287. ;* Call: ***************************************************************
  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
  294.         push    eax
  295.         mov     eax,[unpack.rep3]
  296.         mov     al,[eax]
  297.         inc     dword [unpack.rep3]
  298.         mov     [unpack.code_],al
  299.         pop     eax
  300. ;--------------------------------------------------------------------
  301. @@:
  302.         ret
  303. ;***********************************************************************
  304.  
  305. ;* Call: ***************************************************************
  306. LzmaLenDecode:
  307. ; in: eax->prob, edx=posState
  308. ; out: ecx=len
  309.         call    RangeDecoderBitDecode
  310.         jnb     .2
  311.  
  312.         add     eax,4
  313.         call    RangeDecoderBitDecode
  314.         jb      .1
  315.  
  316.         mov     cl,3
  317.         shl     edx,cl
  318.         lea     eax,[eax+edx*4+516]
  319.         call    RangeDecoderBitTreeDecode
  320.         add     ecx,8
  321.         ret
  322. ;--------------------------------------------------------------------
  323. .1:
  324.         add     eax,1028
  325.         mov     cl,8
  326.         call    RangeDecoderBitTreeDecode
  327.         add     ecx,16
  328.         ret
  329. ;--------------------------------------------------------------------
  330. .2:
  331.         mov     cl,3
  332.         shl     edx,cl
  333.         lea     eax,[eax+edx*4+8]
  334. ;***********************************************************************
  335.  
  336. ;* Call: ***************************************************************
  337. RangeDecoderBitTreeDecode:
  338. ; in: eax->probs,ecx=numLevels
  339. ; out: ecx=length; destroys edx
  340.         push    edi
  341.         xor     edx,edx
  342.         inc     edx
  343.         mov     edi,edx
  344.         xchg    edi, eax
  345. ;--------------------------------------------------------------------
  346. @@:
  347.         push    eax
  348.         lea     eax,[edi+edx*4]
  349.         call    RangeDecoderBitDecode
  350.         pop     eax
  351.         adc     dl,dl
  352.         add     al,al
  353.         loop    @b
  354.         sub     dl,al
  355.         pop     edi
  356.         mov     ecx,edx
  357.         ret
  358. ;***********************************************************************
  359.  
  360.