core: switch LZO decompressor to "fast safe" version
[syslinux/sherbszt.git] / core / lzo / lzo1f_d.ash
blob97a103c00ef33daebda9bbfade1e826c3638c66c
1 /* lzo1f_d.ash -- assembler implementation of the LZO1F decompression algorithm
3    This file is part of the LZO real-time data compression library.
5    Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer
6    Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer
7    Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer
8    Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
9    Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
10    Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
11    Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
12    Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
13    Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
14    Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
15    Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
16    Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
17    Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
18    Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
19    Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
20    Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
21    All Rights Reserved.
23    The LZO library is free software; you can redistribute it and/or
24    modify it under the terms of the GNU General Public License as
25    published by the Free Software Foundation; either version 2 of
26    the License, or (at your option) any later version.
28    The LZO library is distributed in the hope that it will be useful,
29    but WITHOUT ANY WARRANTY; without even the implied warranty of
30    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
31    GNU General Public License for more details.
33    You should have received a copy of the GNU General Public License
34    along with the LZO library; see the file COPYING.
35    If not, write to the Free Software Foundation, Inc.,
36    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
38    Markus F.X.J. Oberhumer
39    <markus@oberhumer.com>
40    http://www.oberhumer.com/opensource/lzo/
41  */
44 /***********************************************************************
46 ************************************************************************/
48         ALIGN3
49 .L0:
50         xorl    %eax,%eax
51         movb    (%esi),%al
52         incl    %esi
53         cmpb    $31,%al
54         ja      .LM2
56         orb     %al,%al
57         movl    %eax,%ecx
58         jnz     .L2
60         LODSB
61         orb     %al,%al
62         jnz     2f
63         addl    N_255,%ecx
64         jmp     1b
66         lea     31(%eax,%ecx),%ecx
67 .L2:
68         TEST_OP((%edi,%ecx),%ebx)
69         TEST_IP((%esi,%ecx),%ebx)
70         movb    %cl,%al
71         shrl    $2,%ecx
72         rep
73         movsl
74         andb    $3,%al
75         jz      1f
76         movl    (%esi),%ebx
77         addl    %eax,%esi
78         movl    %ebx,(%edi)
79         addl    %eax,%edi
81         movb    (%esi),%al
82         incl    %esi
83 .LM1:
84         cmpb    $31,%al
85         jbe     .LM21
87 .LM2:
88         cmpb    $223,%al
89         ja      .LM3
91         movl    %eax,%ecx
92         shrl    $2,%eax
93         lea     -1(%edi),%edx
94         andb    $7,%al
95         shrl    $5,%ecx
96         movl    %eax,%ebx
98         movb    (%esi),%al
99         leal    (%ebx,%eax,8),%eax
100         incl    %esi
101 .LM5:
102         subl    %eax,%edx
103         addl    $2,%ecx
104         xchgl   %edx,%esi
105         TEST_LOOKBEHIND(%esi)
106         TEST_OP((%edi,%ecx),%ebx)
107         cmpl    $6,%ecx
108         jb      1f
109         cmpl    $4,%eax
110         jb      1f
111         movb    %cl,%al
112         shrl    $2,%ecx
113         rep
114         movsl
115         andb    $3,%al
116         movb    %al,%cl
118         rep
119         movsb
120         movl    %edx,%esi
121 .LN1:
122         movb    -2(%esi),%cl
123         andl    $3,%ecx
124         jz      .L0
125         movl    (%esi),%eax
126         addl    %ecx,%esi
127         movl    %eax,(%edi)
128         addl    %ecx,%edi
129         xorl    %eax,%eax
130         movb    (%esi),%al
131         incl    %esi
132         jmp     .LM1
133 .LM21:
134         TEST_OP(3(%edi),%edx)
135         shrl    $2,%eax
136         leal    -0x801(%edi),%edx
137         movl    %eax,%ecx
138         movb    (%esi),%al
139         incl    %esi
140         leal    (%ecx,%eax,8),%eax
141         subl    %eax,%edx
142         TEST_LOOKBEHIND(%edx)
143         movl    (%edx),%eax
144         movl    %eax,(%edi)
145         addl    $3,%edi
146         jmp     .LN1
148         LODSB
149         orb     %al,%al
150         jnz     2f
151         addl    N_255,%ecx
152         jmp     1b
154         lea     31(%eax,%ecx),%ecx
155         jmp     .LM4
157         ALIGN3
158 .LM3:
159         andb    $31,%al
160         movl    %eax,%ecx
161         jz      1b
162 .LM4:
163         movl    %edi,%edx
164         movw    (%esi),%ax
165         addl    $2,%esi
166         shrl    $2,%eax
167         jnz     .LM5
169 .LEOF:
170 /****   xorl    %eax,%eax          eax=0 from above */
172         cmpl    $1,%ecx         /* ecx must be 1 */
173         setnz   %al
177 vi:ts=4