Re: LZ: Compression program (and questions for asm programmers)
[Prev][Next][Index][Thread]
> In fact, what I need is a compression algorithm. Once I have that,
> I can start experimenting with putting programs into another string
> as .db's and trying to run it. In fact, I guess I could do that
> now without compression.
The most common compression algorithm is as follows:
The program finds repeated characters and instead of reusing the characters
it simply goes back offset bytes and copies length bytes past it, in the
for <offset,length> For example:
%% = 2 Bytes for EOL, CR
^Z = 1 Byte for EOF
Peter_Piper_picked_a_peck_of_pickled_peppers.%%
A_peck_of_pickled_peppers_Peter_Piper_picked.%%
If_Peter_Piper_picked_a_peck_of_pickled_peppers,%%
where's_the_peck_of_pickled_peppers_Peter_Piper_picked?%%
^Z (202 Bytes)
becomes:
Peter_Pip<6,3>picked_a_peck_of<17,5>l<18,3>peppers.%%
A<28,24>_<73,18>.%% If_<97,44>,%%
where's_the<38,24><83,19>?%%^Z (78 Bytes)
By replacing repeated strings with pointers to the previous occurence, the
file has been shrunk to 78 bytes from 202, a saving
of 124 bytes.
This method is known as the Lempel-Ziv algorithm.
Mike
References: