Subversion Repositories autosfx

Rev

Blame | Last modification | View Log | RSS feed

  1. #include "stdafx.h"
  2. #pragma hdrstop
  3. /*
  4.  
  5.   Copyright (c) 1990-2007 Info-ZIP.  All rights reserved.
  6.  
  7.   See the accompanying file LICENSE, version 2007-Mar-4 or later
  8.   (the contents of which are also included in zip.h) for terms of use.
  9.   If, for some reason, all these files are missing, the Info-ZIP license
  10.   also may be found at:  ftp://ftp.info-zip.org/pub/infozip/license.html
  11.  
  12.   parts Copyright (C) 1997 Mike White, Eric W. Engler
  13. ************************************************************************
  14.  Copyright (C) 2009, 2010  by Russell J. Peters, Roger Aelbrecht
  15.  
  16.    This file is part of TZipMaster Version 1.9.
  17.  
  18.     TZipMaster is free software: you can redistribute it and/or modify
  19.     it under the terms of the GNU Lesser General Public License as published by
  20.     the Free Software Foundation, either version 3 of the License, or
  21.     (at your option) any later version.
  22.  
  23.     TZipMaster is distributed in the hope that it will be useful,
  24.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  25.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  26.     GNU Lesser General Public License for more details.
  27.  
  28.     You should have received a copy of the GNU Lesser General Public License
  29.     along with TZipMaster.  If not, see <http://www.gnu.org/licenses/>.
  30.  
  31.     contact: problems@delphizip.org (include ZipMaster in the subject).
  32.     updates: http://www.delphizip.org
  33.     DelphiZip maillist subscribe at http://www.freelists.org/list/delphizip
  34. ************************************************************************/
  35. #ifdef _USE_ASM_
  36.         #if defined(__BORLANDC__) && (__BORLANDC__ < 0x0570)
  37.         #pragma inline
  38.         #endif
  39.  
  40. #include "ZipDflt.h"
  41.  
  42. void __fastcall ZipDflt::pqdownheap(ct_data *tree, int k)
  43. {
  44. #pragma warn - rvl
  45. #pragma argsused
  46. //  int v, j, b;
  47.     int v = fheap[k];
  48.     int j = k << 1;       // left son of k
  49.     int htemp;
  50.     asm
  51.     {
  52.  
  53. l1:
  54.         mov       ebx, this
  55.         // ebx = this
  56.         //   While (j <= fheap_len)
  57.         mov       edx, j
  58.         cmp       edx, dword ptr [ebx .fheap_len]
  59.         jg        lx
  60.         //    if (J < fheap_len
  61.         jge       l3
  62.         //      && smaller
  63.         //      tree[j + 1].Freq < tree[j].Freq
  64.         mov       ecx, tree
  65.         mov       edx, j
  66.         mov       edx, dword ptr [ebx+4*edx .fheap+4]
  67.         mov       ax, word ptr [ecx+4*edx]
  68.         mov       edx, j
  69.         mov       edx, dword ptr [ebx+4*edx .fheap]
  70.         cmp       ax, word ptr [ecx+4*edx]
  71.         jb        short l2
  72.         // || (tree[n].Freq == tree[m].Freq
  73.         jne       short l3
  74.         //  && fdepth[j + 1] <= fdepth[j])
  75.         mov       eax, j
  76.         mov       edx, this
  77.         mov       eax, dword ptr [ebx+4*eax .fheap+4]
  78.         mov       cl, byte ptr [ebx+eax .fdepth]
  79.         mov       eax, j
  80.         mov       eax, dword ptr [ebx+4*eax .fheap]
  81.         cmp       cl, byte ptr [ebx+eax .fdepth]
  82.         ja        short l3
  83.  
  84. l2:
  85.         //    j++
  86.         inc       j
  87.  
  88. l3:
  89.         // Exit if v is smaller than both sons
  90.         //   htemp = fheap[j];
  91.         mov       ecx, j
  92.         mov       edx, dword ptr [ebx+4*ecx .fheap]
  93.         mov       htemp, edx
  94.         //      if (smaller(tree, v, htemp)
  95.         //      tree[v].Freq < tree[htemp].Freq
  96.         mov       ecx, tree
  97.         mov       eax, v
  98.         mov       dx, word ptr [ecx+4*eax]
  99.         mov       eax, htemp
  100.         cmp       dx, word ptr [ecx+4*eax]
  101.         jb        short lx
  102.         // || (tree[v].Freq == tree[htemp].Freq
  103.         jne       short l4
  104.         //  && fdepth[v] <= fdepth[htemp])
  105.         mov       eax, v
  106.         mov       cl, byte ptr [ebx+eax .fdepth]
  107.         mov       eax, htemp
  108.         cmp       cl, byte ptr [ebx+eax .fdepth]
  109.         jbe       short lx
  110.  
  111. l4:
  112.         // Exchange v with the smallest son
  113.         //    fheap[k] = htemp;
  114.         mov       ecx, k
  115.         mov       edx, htemp
  116.         mov       dword ptr [ebx+4*ecx .fheap], edx
  117.  
  118.         //    k = j;
  119.         mov       ecx, j
  120.         mov       k, ecx
  121.  
  122.         // And continue down the tree, setting j to the left son of k
  123.         //    j <<= 1;
  124.         shl       j, 1
  125.         #if defined(__BORLANDC__) && (__BORLANDC__ < 0x0550)
  126.         jmp       l1
  127.         #else
  128.         jmp       short l1
  129.         #endif
  130.         // } while
  131.  
  132. lx:
  133.         //  fheap[k] = v;
  134.         mov       ecx, k
  135.         mov       eax, this
  136.         mov       edx, v
  137.         mov       dword ptr [eax+4*ecx .fheap], edx
  138.         // fini
  139.     };
  140. };
  141.  
  142.  
  143.  
  144. unsigned __fastcall bi_reverse(unsigned code, int len)
  145. {
  146. #pragma warn - rvl
  147. #pragma argsused
  148.     asm
  149.     {
  150.         // EAX=code EDX=len
  151.         mov ecx, eax
  152.         xor eax, eax
  153.  
  154. Loop1:
  155.         dec edx
  156.         jl short doneit
  157.         ror ecx, 1
  158.         rcl eax, 1
  159.         jmp short Loop1
  160.  
  161. doneit:
  162.     };
  163. }
  164.  
  165.  
  166. #endif
  167.  
  168.