|
kusano |
7d535a |
/* lzo_asm.h -- LZO assembler stuff
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
This file is part of the LZO real-time data compression library.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
|
|
kusano |
7d535a |
Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
|
|
kusano |
7d535a |
Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
|
|
kusano |
7d535a |
Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
|
|
kusano |
7d535a |
Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
|
|
kusano |
7d535a |
Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
|
|
kusano |
7d535a |
Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
|
|
kusano |
7d535a |
Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
|
|
kusano |
7d535a |
Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
|
|
kusano |
7d535a |
Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
|
|
kusano |
7d535a |
Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
|
|
kusano |
7d535a |
Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
|
|
kusano |
7d535a |
Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
|
|
kusano |
7d535a |
All Rights Reserved.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The LZO library is free software; you can redistribute it and/or
|
|
kusano |
7d535a |
modify it under the terms of the GNU General Public License as
|
|
kusano |
7d535a |
published by the Free Software Foundation; either version 2 of
|
|
kusano |
7d535a |
the License, or (at your option) any later version.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The LZO library is distributed in the hope that it will be useful,
|
|
kusano |
7d535a |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
kusano |
7d535a |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
kusano |
7d535a |
GNU General Public License for more details.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
You should have received a copy of the GNU General Public License
|
|
kusano |
7d535a |
along with the LZO library; see the file COPYING.
|
|
kusano |
7d535a |
If not, write to the Free Software Foundation, Inc.,
|
|
kusano |
7d535a |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Markus F.X.J. Oberhumer
|
|
kusano |
7d535a |
<markus@oberhumer.com></markus@oberhumer.com>
|
|
kusano |
7d535a |
http://www.oberhumer.com/opensource/lzo/
|
|
kusano |
7d535a |
*/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/***********************************************************************
|
|
kusano |
7d535a |
// <asmconfig.h></asmconfig.h>
|
|
kusano |
7d535a |
************************************************************************/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if !defined(__i386__)
|
|
kusano |
7d535a |
# error
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if !defined(IN_CONFIGURE)
|
|
kusano |
7d535a |
#if defined(LZO_HAVE_CONFIG_H)
|
|
kusano |
7d535a |
# include <config.h></config.h>
|
|
kusano |
7d535a |
#else
|
|
kusano |
7d535a |
/* manual configuration - see defaults below */
|
|
kusano |
7d535a |
# if defined(__ELF__)
|
|
kusano |
7d535a |
# define MFX_ASM_HAVE_TYPE
|
|
kusano |
7d535a |
# define MFX_ASM_NAME_NO_UNDERSCORES
|
|
kusano |
7d535a |
# elif defined(__linux__) /* Linux a.out */
|
|
kusano |
7d535a |
# define MFX_ASM_ALIGN_PTWO
|
|
kusano |
7d535a |
# elif defined(__DJGPP__)
|
|
kusano |
7d535a |
# define MFX_ASM_ALIGN_PTWO
|
|
kusano |
7d535a |
# elif defined(__GO32__) /* djgpp v1 */
|
|
kusano |
7d535a |
# define MFX_ASM_CANNOT_USE_EBP
|
|
kusano |
7d535a |
# elif defined(__EMX__)
|
|
kusano |
7d535a |
# define MFX_ASM_ALIGN_PTWO
|
|
kusano |
7d535a |
# define MFX_ASM_CANNOT_USE_EBP
|
|
kusano |
7d535a |
# endif
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if 1 && defined(__ELF__)
|
|
kusano |
7d535a |
.section .note.GNU-stack,"",@progbits
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
#if 0 && defined(__ELF__)
|
|
kusano |
7d535a |
#undef i386
|
|
kusano |
7d535a |
.arch i386
|
|
kusano |
7d535a |
.code32
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/***********************************************************************
|
|
kusano |
7d535a |
// name always uses underscores
|
|
kusano |
7d535a |
// [ OLD: name (default: with underscores) ]
|
|
kusano |
7d535a |
************************************************************************/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if !defined(LZO_ASM_NAME)
|
|
kusano |
7d535a |
# define LZO_ASM_NAME(n) _ ## n
|
|
kusano |
7d535a |
#if 0
|
|
kusano |
7d535a |
# if defined(MFX_ASM_NAME_NO_UNDERSCORES)
|
|
kusano |
7d535a |
# define LZO_ASM_NAME(n) n
|
|
kusano |
7d535a |
# else
|
|
kusano |
7d535a |
# define LZO_ASM_NAME(n) _ ## n
|
|
kusano |
7d535a |
# endif
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/***********************************************************************
|
|
kusano |
7d535a |
// .type (default: do not use)
|
|
kusano |
7d535a |
************************************************************************/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if !defined(LZO_PUBLIC)
|
|
kusano |
7d535a |
#if defined(__LZO_DB__)
|
|
kusano |
7d535a |
# define LZO_PUBLIC(func) \
|
|
kusano |
7d535a |
.p2align 4 ; .byte 0,0,0,0,0,0,0 ; .ascii "LZO_START"
|
|
kusano |
7d535a |
# define LZO_PUBLIC_END(func) \
|
|
kusano |
7d535a |
.p2align 4,0x90 ; .ascii "LZO_END"
|
|
kusano |
7d535a |
#elif defined(MFX_ASM_HAVE_TYPE)
|
|
kusano |
7d535a |
# define LZO_PUBLIC(func) \
|
|
kusano |
7d535a |
ALIGN3 ; .type LZO_ASM_NAME(func),@function ; \
|
|
kusano |
7d535a |
.globl LZO_ASM_NAME(func) ; LZO_ASM_NAME(func):
|
|
kusano |
7d535a |
# define LZO_PUBLIC_END(func) \
|
|
kusano |
7d535a |
.size LZO_ASM_NAME(func),.-LZO_ASM_NAME(func)
|
|
kusano |
7d535a |
#else
|
|
kusano |
7d535a |
# define LZO_PUBLIC(func) \
|
|
kusano |
7d535a |
ALIGN3 ; .globl LZO_ASM_NAME(func) ; LZO_ASM_NAME(func):
|
|
kusano |
7d535a |
# define LZO_PUBLIC_END(func)
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/***********************************************************************
|
|
kusano |
7d535a |
// .align (default: bytes)
|
|
kusano |
7d535a |
************************************************************************/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if !defined(MFX_ASM_ALIGN_BYTES) && !defined(MFX_ASM_ALIGN_PTWO)
|
|
kusano |
7d535a |
# define MFX_ASM_ALIGN_BYTES
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if !defined(LZO_ASM_ALIGN)
|
|
kusano |
7d535a |
# if defined(MFX_ASM_ALIGN_PTWO)
|
|
kusano |
7d535a |
# define LZO_ASM_ALIGN(x) .align x
|
|
kusano |
7d535a |
# else
|
|
kusano |
7d535a |
# define LZO_ASM_ALIGN(x) .align (1 << (x))
|
|
kusano |
7d535a |
# endif
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#define ALIGN1 LZO_ASM_ALIGN(1)
|
|
kusano |
7d535a |
#define ALIGN2 LZO_ASM_ALIGN(2)
|
|
kusano |
7d535a |
#define ALIGN3 LZO_ASM_ALIGN(3)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/***********************************************************************
|
|
kusano |
7d535a |
// ebp usage (default: can use)
|
|
kusano |
7d535a |
************************************************************************/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if !defined(MFX_ASM_CANNOT_USE_EBP)
|
|
kusano |
7d535a |
# if 1 && !defined(N_3_EBP) && !defined(N_255_EBP)
|
|
kusano |
7d535a |
# define N_3_EBP
|
|
kusano |
7d535a |
# endif
|
|
kusano |
7d535a |
# if 0 && !defined(N_3_EBP) && !defined(N_255_EBP)
|
|
kusano |
7d535a |
# define N_255_EBP
|
|
kusano |
7d535a |
# endif
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if defined(N_3_EBP) && defined(N_255_EBP)
|
|
kusano |
7d535a |
# error
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
#if defined(MFX_ASM_CANNOT_USE_EBP)
|
|
kusano |
7d535a |
# if defined(N_3_EBP) || defined(N_255_EBP)
|
|
kusano |
7d535a |
# error
|
|
kusano |
7d535a |
# endif
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if !defined(N_3)
|
|
kusano |
7d535a |
# if defined(N_3_EBP)
|
|
kusano |
7d535a |
# define N_3 %ebp
|
|
kusano |
7d535a |
# else
|
|
kusano |
7d535a |
# define N_3 $3
|
|
kusano |
7d535a |
# endif
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if !defined(N_255)
|
|
kusano |
7d535a |
# if defined(N_255_EBP)
|
|
kusano |
7d535a |
# define N_255 %ebp
|
|
kusano |
7d535a |
# define NOTL_3(r) xorl %ebp,r
|
|
kusano |
7d535a |
# else
|
|
kusano |
7d535a |
# define N_255 $255
|
|
kusano |
7d535a |
# endif
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if !defined(NOTL_3)
|
|
kusano |
7d535a |
# define NOTL_3(r) xorl N_3,r
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/***********************************************************************
|
|
kusano |
7d535a |
//
|
|
kusano |
7d535a |
************************************************************************/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#ifndef INP
|
|
kusano |
7d535a |
#define INP 4+36(%esp)
|
|
kusano |
7d535a |
#define INS 8+36(%esp)
|
|
kusano |
7d535a |
#define OUTP 12+36(%esp)
|
|
kusano |
7d535a |
#define OUTS 16+36(%esp)
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#define INEND 4(%esp)
|
|
kusano |
7d535a |
#define OUTEND (%esp)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if defined(LZO_TEST_DECOMPRESS_OVERRUN_INPUT)
|
|
kusano |
7d535a |
# define TEST_IP_R(r) cmpl r,INEND ; jb .L_input_overrun
|
|
kusano |
7d535a |
# define TEST_IP(addr,r) leal addr,r ; TEST_IP_R(r)
|
|
kusano |
7d535a |
#else
|
|
kusano |
7d535a |
# define TEST_IP_R(r)
|
|
kusano |
7d535a |
# define TEST_IP(addr,r)
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if defined(LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT)
|
|
kusano |
7d535a |
# define TEST_OP_R(r) cmpl r,OUTEND ; jb .L_output_overrun
|
|
kusano |
7d535a |
# define TEST_OP(addr,r) leal addr,r ; TEST_OP_R(r)
|
|
kusano |
7d535a |
#else
|
|
kusano |
7d535a |
# define TEST_OP_R(r)
|
|
kusano |
7d535a |
# define TEST_OP(addr,r)
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if defined(LZO_TEST_DECOMPRESS_OVERRUN_LOOKBEHIND)
|
|
kusano |
7d535a |
# define TEST_LOOKBEHIND(r) cmpl OUTP,r ; jb .L_lookbehind_overrun
|
|
kusano |
7d535a |
#else
|
|
kusano |
7d535a |
# define TEST_LOOKBEHIND(r)
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/***********************************************************************
|
|
kusano |
7d535a |
//
|
|
kusano |
7d535a |
************************************************************************/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#define LODSB movb (%esi),%al ; incl %esi
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#define MOVSB(r1,r2,x) movb (r1),x ; incl r1 ; movb x,(r2) ; incl r2
|
|
kusano |
7d535a |
#define MOVSW(r1,r2,x) movb (r1),x ; movb x,(r2) ; \
|
|
kusano |
7d535a |
movb 1(r1),x ; addl $2,r1 ; \
|
|
kusano |
7d535a |
movb x,1(r2) ; addl $2,r2
|
|
kusano |
7d535a |
#define MOVSL(r1,r2,x) movl (r1),x ; addl $4,r1 ; movl x,(r2) ; addl $4,r2
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if defined(LZO_DEBUG)
|
|
kusano |
7d535a |
#define COPYB_C(r1,r2,x,rc) \
|
|
kusano |
7d535a |
cmpl $0,rc ; jz .L_assert_fail; \
|
|
kusano |
7d535a |
9: MOVSB(r1,r2,x) ; decl rc ; jnz 9b
|
|
kusano |
7d535a |
#define COPYL_C(r1,r2,x,rc) \
|
|
kusano |
7d535a |
cmpl $0,rc ; jz .L_assert_fail; \
|
|
kusano |
7d535a |
9: MOVSL(r1,r2,x) ; decl rc ; jnz 9b
|
|
kusano |
7d535a |
#else
|
|
kusano |
7d535a |
#define COPYB_C(r1,r2,x,rc) \
|
|
kusano |
7d535a |
9: MOVSB(r1,r2,x) ; decl rc ; jnz 9b
|
|
kusano |
7d535a |
#define COPYL_C(r1,r2,x,rc) \
|
|
kusano |
7d535a |
9: MOVSL(r1,r2,x) ; decl rc ; jnz 9b
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#define COPYB(r1,r2,x) COPYB_C(r1,r2,x,%ecx)
|
|
kusano |
7d535a |
#define COPYL(r1,r2,x) COPYL_C(r1,r2,x,%ecx)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/***********************************************************************
|
|
kusano |
7d535a |
// not used
|
|
kusano |
7d535a |
************************************************************************/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if 0
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if 0
|
|
kusano |
7d535a |
#define REP_MOVSB(x) rep ; movsb
|
|
kusano |
7d535a |
#define REP_MOVSL(x) shrl $2,%ecx ; rep ; movsl
|
|
kusano |
7d535a |
#elif 1
|
|
kusano |
7d535a |
#define REP_MOVSB(x) COPYB(%esi,%edi,x)
|
|
kusano |
7d535a |
#define REP_MOVSL(x) shrl $2,%ecx ; COPYL(%esi,%edi,x)
|
|
kusano |
7d535a |
#else
|
|
kusano |
7d535a |
#define REP_MOVSB(x) rep ; movsb
|
|
kusano |
7d535a |
#define REP_MOVSL(x) jmp 9f ; 8: movsb ; decl %ecx ; \
|
|
kusano |
7d535a |
9: testl $3,%edi ; jnz 8b ; \
|
|
kusano |
7d535a |
movl %ecx,x ; shrl $2,%ecx ; andl $3,x ; \
|
|
kusano |
7d535a |
rep ; movsl ; movl x,%ecx ; rep ; movsb
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if 1
|
|
kusano |
7d535a |
#define NEGL(x) negl x
|
|
kusano |
7d535a |
#else
|
|
kusano |
7d535a |
#define NEGL(x) xorl $-1,x ; incl x
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*
|
|
kusano |
7d535a |
vi:ts=4
|
|
kusano |
7d535a |
*/
|
|
kusano |
7d535a |
|