Tizen 2.1 base
[external/lzo2.git] / asm / i386 / src / lzo1c_d.ash
1 /* lzo1c_d.ash -- assembler implementation of the LZO1C decompression algorithm
2
3    This file is part of the LZO real-time data compression library.
4
5    Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
6    Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
7    Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
8    Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
9    Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
10    Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
11    Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
12    Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
13    Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
14    Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
15    Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
16    Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
17    Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
18    All Rights Reserved.
19
20    The LZO library is free software; you can redistribute it and/or
21    modify it under the terms of the GNU General Public License as
22    published by the Free Software Foundation; either version 2 of
23    the License, or (at your option) any later version.
24
25    The LZO library is distributed in the hope that it will be useful,
26    but WITHOUT ANY WARRANTY; without even the implied warranty of
27    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28    GNU General Public License for more details.
29
30    You should have received a copy of the GNU General Public License
31    along with the LZO library; see the file COPYING.
32    If not, write to the Free Software Foundation, Inc.,
33    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
34
35    Markus F.X.J. Oberhumer
36    <markus@oberhumer.com>
37    http://www.oberhumer.com/opensource/lzo/
38  */
39
40
41 /***********************************************************************
42 //
43 ************************************************************************/
44
45         ALIGN3
46 .L1:
47         xorl    %eax,%eax
48         movb    (%esi),%al
49         incl    %esi
50         cmpb    $32,%al
51         jnb     .LMATCH
52
53         orb     %al,%al
54         jz      .L12
55         movl    %eax,%ecx
56 .LIT:
57         TEST_OP((%edi,%ecx),%ebx)
58         TEST_IP((%esi,%ecx),%ebx)
59         rep
60         movsb
61 .LM1:
62         movb    (%esi),%al
63         incl    %esi
64
65         cmpb    $32,%al
66         jb      .LM2
67 .LMATCH:
68         cmpb    $64,%al
69         jb      .LN3
70
71         movl    %eax,%ecx
72         andb    $31,%al
73         leal    -1(%edi),%edx
74         shrl    $5,%ecx
75         subl    %eax,%edx
76         movb    (%esi),%al
77         incl    %esi
78
79         shll    $5,%eax
80         subl    %eax,%edx
81         incl    %ecx
82         xchgl   %esi,%edx
83         TEST_LOOKBEHIND(%esi)
84         TEST_OP((%edi,%ecx),%ebx)
85         rep
86         movsb
87         movl    %edx,%esi
88         jmp     .L1
89
90         ALIGN3
91 .L12:
92         LODSB
93         leal    32(%eax),%ecx
94         cmpb    $248,%al
95         jb      .LIT
96
97         movl    $280,%ecx
98         subb    $248,%al
99         jz      .L11
100         xchgl   %eax,%ecx
101         xorb    %al,%al
102         shll    %cl,%eax
103         xchgl   %eax,%ecx
104 .L11:
105         TEST_OP((%edi,%ecx),%ebx)
106         TEST_IP((%esi,%ecx),%ebx)
107         rep
108         movsb
109         jmp     .L1
110
111         ALIGN3
112 .LM2:
113         leal    -1(%edi),%edx
114         subl    %eax,%edx
115         LODSB
116         shll    $5,%eax
117         subl    %eax,%edx
118         xchgl   %esi,%edx
119         TEST_LOOKBEHIND(%esi)
120         TEST_OP(4(%edi),%ebx)
121         movsb
122         movsb
123         movsb
124         movl    %edx,%esi
125         movsb
126         xorl    %eax,%eax
127         jmp     .LM1
128 .LN3:
129         andb    $31,%al
130         movl    %eax,%ecx
131         jnz     .LN6
132         movb    $31,%cl
133 .LN4:
134         LODSB
135         orb     %al,%al
136         jnz     .LN5
137         addl    N_255,%ecx
138         jmp     .LN4
139
140         ALIGN3
141 .LN5:
142         addl    %eax,%ecx
143 .LN6:
144         movb    (%esi),%al
145         incl    %esi
146
147         movl    %eax,%ebx
148         andb    $63,%al
149         movl    %edi,%edx
150         subl    %eax,%edx
151
152         movb    (%esi),%al
153         incl    %esi
154
155         shll    $6,%eax
156         subl    %eax,%edx
157         cmpl    %edi,%edx
158         jz      .LEOF
159
160         xchgl   %edx,%esi
161         leal    3(%ecx),%ecx
162         TEST_LOOKBEHIND(%esi)
163         TEST_OP((%edi,%ecx),%eax)
164         rep
165         movsb
166
167         movl    %edx,%esi
168         xorl    %eax,%eax
169         shrl    $6,%ebx
170         movl    %ebx,%ecx
171         jnz     .LIT
172         jmp     .L1
173
174 .LEOF:
175 /****   xorl    %eax,%eax          eax=0 from above */
176
177         cmpl    $1,%ecx         /* ecx must be 1 */
178         setnz   %al
179
180
181 /*
182 vi:ts=4
183 */
184