ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Compress-LZV1/lzv1/rlzv2.S
Revision: 1.1
Committed: Thu Sep 27 18:35:29 2001 UTC (22 years, 8 months ago) by root
Branch: MAIN
CVS Tags: HEAD
Log Message:
*** empty log message ***

File Contents

# Content
1 /*
2 * LZV decompression written in assembly.
3 *
4 * Written by Antoine de Maricourt (dumesnil@etca.fr)
5 * 12 Apr 1995
6 *
7 * NOTE: The use of this algorithm may be restricted by some
8 * patent. Please check if this is the case in your
9 * country before using it.
10 *
11 * Interface :
12 * -----------
13 *
14 * int rLZV2 (char *ib, char *ob, int il, int ol);
15 *
16 * ib = input buffer (compressed data)
17 * ob = output buffer (uncompressed data)
18 * il = number of bytes in the input buffer
19 * ol = number of bytes to be uncompressed
20 *
21 * The routine may write more (i.e., 65) bytes than requested
22 * (and could be modified in order to write exactly the requested
23 * number if this is really important). However, it will not write
24 * more than the original number of bytes in the uncompressed
25 * data. The returned value is the number of bytes written to
26 * output buffer.
27 *
28 * The coding method is different from the original one. This
29 * allows matches that can be more distant. This also reduces
30 * the maximum match length from 264 to 65.
31 *
32 * The algorithm and the coding method have been taken from
33 * file lzv.c originaly written by Hermann Vogt, and whose
34 * original copyright notice follows:
35 *
36 * -------
37 * Copyright (c) 1994 Hermann Vogt. Redistribution of this file is
38 * permitted under the GNU Public Licence.
39 *
40 * The method presented here is faster and compresses better
41 * than lzrw1 and lzrw1-a. I named it lzv for "Lev-Zimpel-Vogt".
42 * It uses ideas introduced by Ross Williams in his algorithm
43 * lzrw1 [R. N. Williams (1991): "An Extremly Fast ZIV-Lempel Data
44 * Compression Algorithm", Proceedings IEEE Data Compression
45 * Conference, Snowbird, Utah, 362-371] and by Fiala and Green
46 * in their algorithm a1 [E. R. Fiala, D. H. Greene (1989):
47 * "Data Compression with Finite Windows", Communications of the
48 * ACM, 4, 490-505]. Because lzv differs strongly from both,
49 * I hope there will be no patent problems. The hashing-method
50 * has been stolen from Jean-loup Gailly's (patent free) gzip.
51 * -------
52 * Copyright (c) 1995 Antoine de Maricourt. Redistribution
53 * of this file is permitted under the GNU Public License.
54 */
55
56 #include <linux/linkage.h>
57
58 #define A0 28
59 #define A1 32
60 #define A2 36
61 #define A3 40
62
63 .text
64 ENTRY(ext2_LZV2_decompress)
65 pushl %ebp
66 pushl %edi
67 pushl %esi
68 pushl %ebx # be safe
69 pushl %ecx
70 pushl %edx
71
72 movl A0(%esp), %esi # esi = input buffer
73 movl A1(%esp), %edi # edi = output buffer
74 movl %esi, %ebx
75 addl A2(%esp), %ebx # ebx = input limit
76 movl %edi, %edx
77 addl A3(%esp), %edx # edx = output limit
78 xorl %ecx, %ecx
79 xorl %eax, %eax
80 cld
81
82 ALIGN
83
84 L10: cmpl %esi, %ebx # check for input overflow
85 jna L13
86
87 /*
88 * Get the opcode
89 */
90
91 movb (%esi), %al # load opcode
92 testb $7, %al # test 3 lower bits
93 jne L11
94
95 /*
96 * This is a literal
97 */
98
99 shrb $3, %al # store its len into ecx
100 incb %al
101 movb %al, %cl
102 incl %esi
103 rep; movsb
104 cmpl %edx, %edi # check for output overflow
105 jb L10 # and continue
106 jmp L13
107
108 /*
109 * This is a match
110 */
111
112 ALIGN
113
114 L11: movb %al, %cl
115 andb $7, %cl # store its len into ecx
116 cmpb $7, %cl
117 je L12
118
119 /*
120 * This is a small match
121 */
122
123 addl $2, %ecx
124 shll $5, %eax
125 movb 1(%esi), %al
126 notl %eax
127 lea 2(%esi), %ebp # save next value of esi
128 lea (%edi,%eax), %esi # load pointer to match
129 cmpl A1(%esp), %esi # safety check
130 jb L13
131 rep; movsb # copy the match
132 xorl %eax, %eax
133 movl %ebp, %esi # restore esi
134 cmpl %edx, %edi # check for output overflow
135 jb L10 # and continue
136 jmp L13
137
138 /*
139 * This is a big match or a far match
140 */
141
142 ALIGN
143
144 L12: movb 1(%esi), %cl
145 shll $7, %eax # store the offset into eax
146 movb %cl, %al
147 andb $0xfc, %ah
148 andb $0x03, %al
149 orb %al, %ah
150 movb 2(%esi), %al
151 notl %eax
152 shrb $2, %cl # adjust match len
153 addl $2, %ecx
154 lea 3(%esi), %ebp # save next value of esi
155 lea (%edi,%eax), %esi # load pointer to match
156 cmpl A1(%esp), %esi # safety check
157 jb L13
158 rep; movsb # copy the match
159 xorl %eax, %eax
160 movl %ebp, %esi # restore esi
161 cmpl %edx, %edi # check for output overflow
162 jb L10 # and continue
163
164 /*
165 * The end.
166 */
167
168 L13: movl %edi, %eax
169 subl A1(%esp),%eax
170
171 popl %edx
172 popl %ecx
173 popl %ebx
174 popl %esi
175 popl %edi
176 popl %ebp
177 ret
178