home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 June / SIMTEL_0692.cdr / msdos / filutl / shrink.arc / SHRINK.DOC < prev   
Text File  |  1988-06-01  |  5KB  |  99 lines

  1.             SHRINK 1.0   Copyright (c) 1988   Thomas G. Hanlin III
  2.  
  3.                         Program Compression Utility
  4.                                  06/01/88
  5.  
  6.  
  7.  
  8. Using SHRINK:
  9.  
  10.    This utility compresses .COM files without affecting the way you run them.
  11.    Its compression scheme is simple and will not work on all files, but may
  12.    produce impressive results depending on the particular file.  If SHRINK is
  13.    unable to compress the file, it will abort without doing anything.
  14.    Otherwise, it will overwrite the old file with the smaller, compressed
  15.    file.  Note that this will save only disk space, not memory.  You must
  16.    have at least 64K of memory available to run a compressed program.  The
  17.    larger the program is, the better chance SHRINK has to compress it... but
  18.    SHRINK can only handle programs up to 30,000 bytes long.
  19.  
  20.    NOTE that SHRINK is not compatible with every program.  In some cases, a
  21.    program compressed with SHRINK will no longer run.  Do not use SHRINK on a
  22.    program unless you have a backup copy, just in case!  Some files known not
  23.    to compress properly with SHRINK are: BURGER.COM, the Landmark Speed Test,
  24.    PKARC, and PKXARC.
  25.  
  26.    The average compression rate seems to be around 7% for files that SHRINK
  27.    is able to compress, but I've seen compression rates of 46% and higher.
  28.    It depends entirely on the program.
  29.  
  30.    To use SHRINK, just type "SHRINK filename" (without the quotes), where
  31.    "filename" is the name of the .COM file to shrink.  SHRINK will only work
  32.    properly on .COM files, so if you do not type a file extension, ".COM" is
  33.    assumed.  If SHRINK can compress the file, it will do so in place,
  34.    modifying the file you specified... so be sure to make a backup copy of
  35.    the file before SHRINKing it, in case something goes wrong.
  36.  
  37.  
  38.  
  39. Distributing SHRINK:
  40.  
  41.    The SHRINK utility is protected by copyright, and may be distributed only
  42.    according to the following limitations:
  43.  
  44.    1) No price may be charged, other than a disk copying/mailing fee which
  45.    may not exceed $6.00.
  46.  
  47.    2) The utility and documentation must be included together, in unmodified
  48.    form.  This includes the SHRINK.COM and SHRINK.DOC files.
  49.  
  50.    Programs compressed with SHRINK may be distributed without royalties or
  51.    licensing.  Please do not distribute a compressed program without the
  52.    author's permission, however, as this may result in a violation of his
  53.    copyright.
  54.  
  55.  
  56.  
  57. Warning:
  58.  
  59.    I've warned you before, now let me say it again... back up your programs
  60.    before using SHRINK on them!  Although SHRINK works fine in most cases, it
  61.    is known to be incompatible with some programs.  You will simply have to
  62.    find out for yourself whether your particular programs will work with
  63.    SHRINK.  Please notify me of any incompatibilities, and I'll try to keep
  64.    track of them (and find out what is causing the problem)... but I won't
  65.    guarantee that I'll be able to fix it, and I won't be responsible for any
  66.    damages you may accumulate through your carelessness.
  67.  
  68.  
  69.  
  70. Tech Notes:
  71.  
  72.    The SHRINK utility works by compressing a COM-format executable file,
  73.    using the inefficient but simple Run Length Encoding compression scheme to
  74.    turn the code into an encoded data stream.  The flag used for RLE is
  75.    chosen by scanning the file for the least-frequently-used character, for
  76.    maximum efficiency.  The encoded program is written back to disk under the
  77.    original file name, with a relocating decoder attached to the start of the
  78.    file.
  79.  
  80.    When the .COM file executes, control passes to the relocating decoder,
  81.    which relocates itself (and the encoded data) higher in memory.  It then
  82.    decodes the program into the same place it would have been loaded if it
  83.    were not encoded... resets the registers and flags to their original
  84.    form... and starts the program just as if there had never been any
  85.    encoding.
  86.  
  87.    So why doesn't it work for all .COM files?  I really don't know.  Any
  88.    suggestions would be appreciated.
  89.  
  90.    Why did I choose RLE compression?  I did so for a number of reasons.  One,
  91.    it's fast, both for encoding and decoding.  The SHRINK utility imposes no
  92.    noticeable loss of speed on executing a program.  Two, it's simple, which
  93.    keeps it small.  The compression overhead, so far as memory is concerned,
  94.    is equal to the length of the relocating decoder.  With RLE compression,
  95.    this decoder is only 82 bytes, which is insignificant.  Other coding
  96.    schemes might be more efficient, but would have a far greater amount of
  97.    overhead to overcome.  Since no compression method I've seen appears to be
  98.    terribly effective on .COM files anyway, RLE is good enough.
  99.