-------------------------------------------------------------------- SHRINK 2.0 Copyright (c) 1988-95 Kevin Tseng Program Compression Utility 09/03/95 Using SHRINK 2.0: This utility compresses .COM files without affecting the way you run them. Its compression scheme is simple and will work on _all_ files, but may produce impressive results depending on the particular file. If SHRINK 2.0 is unable to compress the file, it will abort without doing anything. Otherwise, it will overwrite the old file with the smaller, compressed file. Note that this will save only disk space, not memory. The larger the program is, the better chance SHRINK 2.0 has to compress it... NOTE that SHRINK 2.0 is _100%_ compatible with every program. _3_FATAL_bugS in original_SHRINK_1.0 by Thomas_G._Hanlin_III had been fixed. The average compression rate seems to be around 7% for files that SHRINK 2.0 is able to compress, but I've seen compression rates of 46% and higher. It depends entirely on the program. To use SHRINK 2.0, just type "SHRINK2 filename" (without the quotes), where "filename" is the name of the .COM file to shrink. SHRINK 2.0 will only work properly on .COM files, so if you do not type a file extension, ".COM" is assumed. If SHRINK 2.0 can compress the file, it will do so in place, modifying the file you specified... so be sure to make a backup copy of the file before SHRINKing it, in case something goes wrong. Distributing SHRINK 2.0: The SHRINK 2.0 utility is protected by copyright, and may be distributed only according to the following limitations: 1) No price may be charged, other than a disk copying/mailing fee. 2) The utility and documentation must be included together, in unmodified form. This includes the SHRINK2.COM and SHRINK2.DOC files. Programs compressed with SHRINK 2.0 may be distributed without royalties or licensing. Please do not distribute a compressed program without the author's permission, however, as this may result in a violation of his copyright. Tech Notes: The SHRINK 2.0 utility works by compressing a COM-format executable file, using the inefficient but simple _SHRINK2_ Run Length Encoding compression scheme to turn the code into an encoded data stream. The flag used for _SHRINK2_ RLE is chosen by scanning the file for the least-frequently-used character, for maximum efficiency. The encoded program is written back to disk under the original file name, with a relocating decoder attached to the start of the file. When the .COM file executes, control passes to the relocating decoder, which relocates itself (and the encoded data) higher in memory. It then decodes the program into the same place it would have been loaded if it were not encoded... resets the registers and flags to their original form... and starts the program just as if there had never been any encoding. Why did I choose _SHRINK2_ RLE compression? I did so for a number of reasons. One, it's fast, both for encoding and decoding. The SHRINK 2.0 utility imposes no noticeable loss of speed on executing a program. Two, it's simple, which keeps it small. With RLE compression, this decoder is quite tiny, which is insignificant. Other coding schemes might be more efficient, but would have a far greater amount of overhead to overcome. Since no compression method I've seen appears to be terribly effective on .COM files anyway, _SHRINK2_ RLE is good enough. assume [RLE flag] = [ff], [input data stream] = [c3 01 01 01 01 01 02 02 ff] --------------------- [-- ^^^^^^^^^^^^^^ -- -- ^^] [output data stream]: [c3 01 ff 05 02 02 ff 00] -- --------------------- [-- ^^^^^^^^ -- -- ^^^^^] -- data length < 2 is not encoded, data length = 0 mean [input data] = [RLE flag] --------------------------------------------------------------------