mirror of
git://git.gnupg.org/gnupg.git
synced 2025-02-01 16:33:02 +01:00
These are special i386 files for use on OpenBSD, which (at least until
version 3.1) has an older assembler that won't work with the files in i386.
This commit is contained in:
parent
553ac3f08c
commit
78f3138150
3
mpi/i386-openbsd/README
Normal file
3
mpi/i386-openbsd/README
Normal file
@ -0,0 +1,3 @@
|
||||
These are special i386 files for use on OpenBSD, which (at least until
|
||||
version 3.1) has an older assembler that won't work with the files in
|
||||
i386.
|
9
mpi/i386-openbsd/distfiles
Normal file
9
mpi/i386-openbsd/distfiles
Normal file
@ -0,0 +1,9 @@
|
||||
mpih-add1.S
|
||||
mpih-mul1.S
|
||||
mpih-mul2.S
|
||||
mpih-mul3.S
|
||||
mpih-lshift.S
|
||||
mpih-rshift.S
|
||||
mpih-sub1.S
|
||||
syntax.h
|
||||
|
118
mpi/i386-openbsd/mpih-add1.S
Normal file
118
mpi/i386-openbsd/mpih-add1.S
Normal file
@ -0,0 +1,118 @@
|
||||
/* i80386 add_n -- Add two limb vectors of the same length > 0 and store
|
||||
* sum in a third limb vector.
|
||||
*
|
||||
* Copyright (C) 1992, 1994, 1995, 1998,
|
||||
* 2001 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GnuPG.
|
||||
*
|
||||
* GnuPG is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GnuPG is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
* way the data is stored; this is to support the abstraction
|
||||
* of an optional secure memory allocation which may be used
|
||||
* to avoid revealing of sensitive data due to paging etc.
|
||||
* The GNU MP Library itself is published under the LGPL;
|
||||
* however I decided to publish this code under the plain GPL.
|
||||
*/
|
||||
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* mpihelp_add_n( mpi_ptr_t res_ptr, (sp + 4)
|
||||
* mpi_ptr_t s1_ptr, (sp + 8)
|
||||
* mpi_ptr_t s2_ptr, (sp + 12)
|
||||
* mpi_size_t size) (sp + 16)
|
||||
*/
|
||||
|
||||
.text
|
||||
ALIGN (3)
|
||||
.globl C_SYMBOL_NAME(mpihelp_add_n)
|
||||
C_SYMBOL_NAME(mpihelp_add_n:)
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
|
||||
movl 12(%esp),%edi /* res_ptr */
|
||||
movl 16(%esp),%esi /* s1_ptr */
|
||||
movl 20(%esp),%edx /* s2_ptr */
|
||||
movl 24(%esp),%ecx /* size */
|
||||
|
||||
movl %ecx,%eax
|
||||
shrl $3,%ecx /* compute count for unrolled loop */
|
||||
negl %eax
|
||||
andl $7,%eax /* get index where to start loop */
|
||||
jz Loop /* necessary special case for 0 */
|
||||
incl %ecx /* adjust loop count */
|
||||
shll $2,%eax /* adjustment for pointers... */
|
||||
subl %eax,%edi /* ... since they are offset ... */
|
||||
subl %eax,%esi /* ... by a constant when we ... */
|
||||
subl %eax,%edx /* ... enter the loop */
|
||||
shrl $2,%eax /* restore previous value */
|
||||
#ifdef PIC
|
||||
/* Calculate start address in loop for PIC. Due to limitations in some
|
||||
assemblers, Loop-L0-3 cannot be put into the leal */
|
||||
call L0
|
||||
L0: leal (%eax,%eax,8),%eax
|
||||
addl (%esp),%eax
|
||||
addl $(Loop-L0-3),%eax
|
||||
addl $4,%esp
|
||||
#else
|
||||
/* Calculate start address in loop for non-PIC. */
|
||||
leal (Loop - 3)(%eax,%eax,8),%eax
|
||||
#endif
|
||||
jmp *%eax /* jump into loop */
|
||||
ALIGN (3)
|
||||
Loop: movl (%esi),%eax
|
||||
adcl (%edx),%eax
|
||||
movl %eax,(%edi)
|
||||
movl 4(%esi),%eax
|
||||
adcl 4(%edx),%eax
|
||||
movl %eax,4(%edi)
|
||||
movl 8(%esi),%eax
|
||||
adcl 8(%edx),%eax
|
||||
movl %eax,8(%edi)
|
||||
movl 12(%esi),%eax
|
||||
adcl 12(%edx),%eax
|
||||
movl %eax,12(%edi)
|
||||
movl 16(%esi),%eax
|
||||
adcl 16(%edx),%eax
|
||||
movl %eax,16(%edi)
|
||||
movl 20(%esi),%eax
|
||||
adcl 20(%edx),%eax
|
||||
movl %eax,20(%edi)
|
||||
movl 24(%esi),%eax
|
||||
adcl 24(%edx),%eax
|
||||
movl %eax,24(%edi)
|
||||
movl 28(%esi),%eax
|
||||
adcl 28(%edx),%eax
|
||||
movl %eax,28(%edi)
|
||||
leal 32(%edi),%edi
|
||||
leal 32(%esi),%esi
|
||||
leal 32(%edx),%edx
|
||||
decl %ecx
|
||||
jnz Loop
|
||||
|
||||
sbbl %eax,%eax
|
||||
negl %eax
|
||||
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
|
96
mpi/i386-openbsd/mpih-lshift.S
Normal file
96
mpi/i386-openbsd/mpih-lshift.S
Normal file
@ -0,0 +1,96 @@
|
||||
/* i80386 lshift
|
||||
* Copyright (C) 1992, 1994, 1998,
|
||||
* 2001 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GnuPG.
|
||||
*
|
||||
* GnuPG is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GnuPG is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
* way the data is stored; this is to support the abstraction
|
||||
* of an optional secure memory allocation which may be used
|
||||
* to avoid revealing of sensitive data due to paging etc.
|
||||
* The GNU MP Library itself is published under the LGPL;
|
||||
* however I decided to publish this code under the plain GPL.
|
||||
*/
|
||||
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* mpihelp_lshift( mpi_ptr_t wp, (sp + 4)
|
||||
* mpi_ptr_t up, (sp + 8)
|
||||
* mpi_size_t usize, (sp + 12)
|
||||
* unsigned cnt) (sp + 16)
|
||||
*/
|
||||
|
||||
.text
|
||||
ALIGN (3)
|
||||
.globl C_SYMBOL_NAME(mpihelp_lshift)
|
||||
C_SYMBOL_NAME(mpihelp_lshift:)
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %ebx
|
||||
|
||||
movl 16(%esp),%edi /* res_ptr */
|
||||
movl 20(%esp),%esi /* s_ptr */
|
||||
movl 24(%esp),%edx /* size */
|
||||
movl 28(%esp),%ecx /* cnt */
|
||||
|
||||
subl $4,%esi /* adjust s_ptr */
|
||||
|
||||
movl (%esi,%edx,4),%ebx /* read most significant limb */
|
||||
xorl %eax,%eax
|
||||
shldl %cl,%ebx,%eax /* compute carry limb */
|
||||
decl %edx
|
||||
jz Lend
|
||||
pushl %eax /* push carry limb onto stack */
|
||||
testb $1,%edx
|
||||
jnz L1 /* enter loop in the middle */
|
||||
movl %ebx,%eax
|
||||
|
||||
ALIGN (3)
|
||||
Loop: movl (%esi,%edx,4),%ebx /* load next lower limb */
|
||||
shldl %cl,%ebx,%eax /* compute result limb */
|
||||
movl %eax,(%edi,%edx,4) /* store it */
|
||||
decl %edx
|
||||
L1: movl (%esi,%edx,4),%eax
|
||||
shldl %cl,%eax,%ebx
|
||||
movl %ebx,(%edi,%edx,4)
|
||||
decl %edx
|
||||
jnz Loop
|
||||
|
||||
shll %cl,%eax /* compute least significant limb */
|
||||
movl %eax,(%edi) /* store it */
|
||||
|
||||
popl %eax /* pop carry limb */
|
||||
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
|
||||
Lend: shll %cl,%ebx /* compute least significant limb */
|
||||
movl %ebx,(%edi) /* store it */
|
||||
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
|
86
mpi/i386-openbsd/mpih-mul1.S
Normal file
86
mpi/i386-openbsd/mpih-mul1.S
Normal file
@ -0,0 +1,86 @@
|
||||
/* i80386 mul_1 -- Multiply a limb vector with a limb and store
|
||||
* the result in a second limb vector.
|
||||
* Copyright (C) 1992, 1994, 1998,
|
||||
* 2001 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GnuPG.
|
||||
*
|
||||
* GnuPG is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GnuPG is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
* way the data is stored; this is to support the abstraction
|
||||
* of an optional secure memory allocation which may be used
|
||||
* to avoid revealing of sensitive data due to paging etc.
|
||||
* The GNU MP Library itself is published under the LGPL;
|
||||
* however I decided to publish this code under the plain GPL.
|
||||
*/
|
||||
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* mpihelp_mul_1( mpi_ptr_t res_ptr, (sp + 4)
|
||||
* mpi_ptr_t s1_ptr, (sp + 8)
|
||||
* mpi_size_t s1_size, (sp + 12)
|
||||
* mpi_limb_t s2_limb) (sp + 16)
|
||||
*/
|
||||
|
||||
#define res_ptr edi
|
||||
#define s1_ptr esi
|
||||
#define size ecx
|
||||
#define s2_limb ebp
|
||||
|
||||
TEXT
|
||||
ALIGN (3)
|
||||
GLOBL C_SYMBOL_NAME(mpihelp_mul_1)
|
||||
C_SYMBOL_NAME(mpihelp_mul_1:)
|
||||
|
||||
INSN1(push,l ,R(edi))
|
||||
INSN1(push,l ,R(esi))
|
||||
INSN1(push,l ,R(ebx))
|
||||
INSN1(push,l ,R(ebp))
|
||||
|
||||
INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20))
|
||||
INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24))
|
||||
INSN2(mov,l ,R(size),MEM_DISP(esp,28))
|
||||
INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32))
|
||||
|
||||
INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,size,4))
|
||||
INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,size,4))
|
||||
INSN1(neg,l ,R(size))
|
||||
INSN2(xor,l ,R(ebx),R(ebx))
|
||||
ALIGN (3)
|
||||
Loop:
|
||||
INSN2(mov,l ,R(eax),MEM_INDEX(s1_ptr,size,4))
|
||||
INSN1(mul,l ,R(s2_limb))
|
||||
INSN2(add,l ,R(eax),R(ebx))
|
||||
INSN2(mov,l ,MEM_INDEX(res_ptr,size,4),R(eax))
|
||||
INSN2(adc,l ,R(edx),$0)
|
||||
INSN2(mov,l ,R(ebx),R(edx))
|
||||
|
||||
INSN1(inc,l ,R(size))
|
||||
INSN1(jnz, ,Loop)
|
||||
INSN2(mov,l ,R(eax),R(ebx))
|
||||
|
||||
INSN1(pop,l ,R(ebp))
|
||||
INSN1(pop,l ,R(ebx))
|
||||
INSN1(pop,l ,R(esi))
|
||||
INSN1(pop,l ,R(edi))
|
||||
ret
|
||||
|
88
mpi/i386-openbsd/mpih-mul2.S
Normal file
88
mpi/i386-openbsd/mpih-mul2.S
Normal file
@ -0,0 +1,88 @@
|
||||
/* i80386 addmul_1 -- Multiply a limb vector with a limb and add
|
||||
* the result to a second limb vector.
|
||||
*
|
||||
* Copyright (C) 1992, 1994, 1998,
|
||||
* 2001 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GnuPG.
|
||||
*
|
||||
* GnuPG is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GnuPG is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
* way the data is stored; this is to support the abstraction
|
||||
* of an optional secure memory allocation which may be used
|
||||
* to avoid revealing of sensitive data due to paging etc.
|
||||
* The GNU MP Library itself is published under the LGPL;
|
||||
* however I decided to publish this code under the plain GPL.
|
||||
*/
|
||||
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* mpihelp_addmul_1( mpi_ptr_t res_ptr, (sp + 4)
|
||||
* mpi_ptr_t s1_ptr, (sp + 8)
|
||||
* mpi_size_t s1_size, (sp + 12)
|
||||
* mpi_limb_t s2_limb) (sp + 16)
|
||||
*/
|
||||
|
||||
#define res_ptr edi
|
||||
#define s1_ptr esi
|
||||
#define size ecx
|
||||
#define s2_limb ebp
|
||||
|
||||
TEXT
|
||||
ALIGN (3)
|
||||
GLOBL C_SYMBOL_NAME(mpihelp_addmul_1)
|
||||
C_SYMBOL_NAME(mpihelp_addmul_1:)
|
||||
|
||||
INSN1(push,l ,R(edi))
|
||||
INSN1(push,l ,R(esi))
|
||||
INSN1(push,l ,R(ebx))
|
||||
INSN1(push,l ,R(ebp))
|
||||
|
||||
INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20))
|
||||
INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24))
|
||||
INSN2(mov,l ,R(size),MEM_DISP(esp,28))
|
||||
INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32))
|
||||
|
||||
INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,size,4))
|
||||
INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,size,4))
|
||||
INSN1(neg,l ,R(size))
|
||||
INSN2(xor,l ,R(ebx),R(ebx))
|
||||
ALIGN (3)
|
||||
Loop:
|
||||
INSN2(mov,l ,R(eax),MEM_INDEX(s1_ptr,size,4))
|
||||
INSN1(mul,l ,R(s2_limb))
|
||||
INSN2(add,l ,R(eax),R(ebx))
|
||||
INSN2(adc,l ,R(edx),$0)
|
||||
INSN2(add,l ,MEM_INDEX(res_ptr,size,4),R(eax))
|
||||
INSN2(adc,l ,R(edx),$0)
|
||||
INSN2(mov,l ,R(ebx),R(edx))
|
||||
|
||||
INSN1(inc,l ,R(size))
|
||||
INSN1(jnz, ,Loop)
|
||||
INSN2(mov,l ,R(eax),R(ebx))
|
||||
|
||||
INSN1(pop,l ,R(ebp))
|
||||
INSN1(pop,l ,R(ebx))
|
||||
INSN1(pop,l ,R(esi))
|
||||
INSN1(pop,l ,R(edi))
|
||||
ret
|
||||
|
88
mpi/i386-openbsd/mpih-mul3.S
Normal file
88
mpi/i386-openbsd/mpih-mul3.S
Normal file
@ -0,0 +1,88 @@
|
||||
/* i80386 submul_1 -- Multiply a limb vector with a limb and add
|
||||
* the result to a second limb vector.
|
||||
*
|
||||
* Copyright (C) 1992, 1994, 1998,
|
||||
* 2001 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GnuPG.
|
||||
*
|
||||
* GnuPG is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GnuPG is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
* way the data is stored; this is to support the abstraction
|
||||
* of an optional secure memory allocation which may be used
|
||||
* to avoid revealing of sensitive data due to paging etc.
|
||||
* The GNU MP Library itself is published under the LGPL;
|
||||
* however I decided to publish this code under the plain GPL.
|
||||
*/
|
||||
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* mpihelp_submul_1( mpi_ptr_t res_ptr, (sp + 4)
|
||||
* mpi_ptr_t s1_ptr, (sp + 8)
|
||||
* mpi_size_t s1_size, (sp + 12)
|
||||
* mpi_limb_t s2_limb) (sp + 16)
|
||||
*/
|
||||
|
||||
#define res_ptr edi
|
||||
#define s1_ptr esi
|
||||
#define size ecx
|
||||
#define s2_limb ebp
|
||||
|
||||
TEXT
|
||||
ALIGN (3)
|
||||
GLOBL C_SYMBOL_NAME(mpihelp_submul_1)
|
||||
C_SYMBOL_NAME(mpihelp_submul_1:)
|
||||
|
||||
INSN1(push,l ,R(edi))
|
||||
INSN1(push,l ,R(esi))
|
||||
INSN1(push,l ,R(ebx))
|
||||
INSN1(push,l ,R(ebp))
|
||||
|
||||
INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20))
|
||||
INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24))
|
||||
INSN2(mov,l ,R(size),MEM_DISP(esp,28))
|
||||
INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32))
|
||||
|
||||
INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,size,4))
|
||||
INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,size,4))
|
||||
INSN1(neg,l ,R(size))
|
||||
INSN2(xor,l ,R(ebx),R(ebx))
|
||||
ALIGN (3)
|
||||
Loop:
|
||||
INSN2(mov,l ,R(eax),MEM_INDEX(s1_ptr,size,4))
|
||||
INSN1(mul,l ,R(s2_limb))
|
||||
INSN2(add,l ,R(eax),R(ebx))
|
||||
INSN2(adc,l ,R(edx),$0)
|
||||
INSN2(sub,l ,MEM_INDEX(res_ptr,size,4),R(eax))
|
||||
INSN2(adc,l ,R(edx),$0)
|
||||
INSN2(mov,l ,R(ebx),R(edx))
|
||||
|
||||
INSN1(inc,l ,R(size))
|
||||
INSN1(jnz, ,Loop)
|
||||
INSN2(mov,l ,R(eax),R(ebx))
|
||||
|
||||
INSN1(pop,l ,R(ebp))
|
||||
INSN1(pop,l ,R(ebx))
|
||||
INSN1(pop,l ,R(esi))
|
||||
INSN1(pop,l ,R(edi))
|
||||
ret
|
||||
|
99
mpi/i386-openbsd/mpih-rshift.S
Normal file
99
mpi/i386-openbsd/mpih-rshift.S
Normal file
@ -0,0 +1,99 @@
|
||||
/* i80386 rshift
|
||||
*
|
||||
* Copyright (C) 1992, 1994, 1998,
|
||||
* 2001 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GnuPG.
|
||||
*
|
||||
* GnuPG is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GnuPG is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
* way the data is stored; this is to support the abstraction
|
||||
* of an optional secure memory allocation which may be used
|
||||
* to avoid revealing of sensitive data due to paging etc.
|
||||
* The GNU MP Library itself is published under the LGPL;
|
||||
* however I decided to publish this code under the plain GPL.
|
||||
*/
|
||||
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* mpihelp_rshift( mpi_ptr_t wp, (sp + 4)
|
||||
* mpi_ptr_t up, (sp + 8)
|
||||
* mpi_size_t usize, (sp + 12)
|
||||
* unsigned cnt) (sp + 16)
|
||||
*/
|
||||
|
||||
.text
|
||||
ALIGN (3)
|
||||
.globl C_SYMBOL_NAME(mpihelp_rshift)
|
||||
C_SYMBOL_NAME(mpihelp_rshift:)
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %ebx
|
||||
|
||||
movl 16(%esp),%edi /* wp */
|
||||
movl 20(%esp),%esi /* up */
|
||||
movl 24(%esp),%edx /* usize */
|
||||
movl 28(%esp),%ecx /* cnt */
|
||||
|
||||
leal -4(%edi,%edx,4),%edi
|
||||
leal (%esi,%edx,4),%esi
|
||||
negl %edx
|
||||
|
||||
movl (%esi,%edx,4),%ebx /* read least significant limb */
|
||||
xorl %eax,%eax
|
||||
shrdl %cl,%ebx,%eax /* compute carry limb */
|
||||
incl %edx
|
||||
jz Lend2
|
||||
pushl %eax /* push carry limb onto stack */
|
||||
testb $1,%edx
|
||||
jnz L2 /* enter loop in the middle */
|
||||
movl %ebx,%eax
|
||||
|
||||
ALIGN (3)
|
||||
Loop2: movl (%esi,%edx,4),%ebx /* load next higher limb */
|
||||
shrdl %cl,%ebx,%eax /* compute result limb */
|
||||
movl %eax,(%edi,%edx,4) /* store it */
|
||||
incl %edx
|
||||
L2: movl (%esi,%edx,4),%eax
|
||||
shrdl %cl,%eax,%ebx
|
||||
movl %ebx,(%edi,%edx,4)
|
||||
incl %edx
|
||||
jnz Loop2
|
||||
|
||||
shrl %cl,%eax /* compute most significant limb */
|
||||
movl %eax,(%edi) /* store it */
|
||||
|
||||
popl %eax /* pop carry limb */
|
||||
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
|
||||
Lend2: shrl %cl,%ebx /* compute most significant limb */
|
||||
movl %ebx,(%edi) /* store it */
|
||||
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
|
119
mpi/i386-openbsd/mpih-sub1.S
Normal file
119
mpi/i386-openbsd/mpih-sub1.S
Normal file
@ -0,0 +1,119 @@
|
||||
/* i80386 sub_n -- Sub two limb vectors of the same length > 0 and store
|
||||
* sum in a third limb vector.
|
||||
*
|
||||
* Copyright (C) 1992, 1994, 1995, 1998,
|
||||
* 2001 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GnuPG.
|
||||
*
|
||||
* GnuPG is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GnuPG is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
* way the data is stored; this is to support the abstraction
|
||||
* of an optional secure memory allocation which may be used
|
||||
* to avoid revealing of sensitive data due to paging etc.
|
||||
* The GNU MP Library itself is published under the LGPL;
|
||||
* however I decided to publish this code under the plain GPL.
|
||||
*/
|
||||
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* mpihelp_sub_n( mpi_ptr_t res_ptr, (sp + 4)
|
||||
* mpi_ptr_t s1_ptr, (sp + 8)
|
||||
* mpi_ptr_t s2_ptr, (sp + 12)
|
||||
* mpi_size_t size) (sp + 16)
|
||||
*/
|
||||
|
||||
|
||||
.text
|
||||
ALIGN (3)
|
||||
.globl C_SYMBOL_NAME(mpihelp_sub_n)
|
||||
C_SYMBOL_NAME(mpihelp_sub_n:)
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
|
||||
movl 12(%esp),%edi /* res_ptr */
|
||||
movl 16(%esp),%esi /* s1_ptr */
|
||||
movl 20(%esp),%edx /* s2_ptr */
|
||||
movl 24(%esp),%ecx /* size */
|
||||
|
||||
movl %ecx,%eax
|
||||
shrl $3,%ecx /* compute count for unrolled loop */
|
||||
negl %eax
|
||||
andl $7,%eax /* get index where to start loop */
|
||||
jz Loop /* necessary special case for 0 */
|
||||
incl %ecx /* adjust loop count */
|
||||
shll $2,%eax /* adjustment for pointers... */
|
||||
subl %eax,%edi /* ... since they are offset ... */
|
||||
subl %eax,%esi /* ... by a constant when we ... */
|
||||
subl %eax,%edx /* ... enter the loop */
|
||||
shrl $2,%eax /* restore previous value */
|
||||
#ifdef PIC
|
||||
/* Calculate start address in loop for PIC. Due to limitations in some
|
||||
assemblers, Loop-L0-3 cannot be put into the leal */
|
||||
call L0
|
||||
L0: leal (%eax,%eax,8),%eax
|
||||
addl (%esp),%eax
|
||||
addl $(Loop-L0-3),%eax
|
||||
addl $4,%esp
|
||||
#else
|
||||
/* Calculate start address in loop for non-PIC. */
|
||||
leal (Loop - 3)(%eax,%eax,8),%eax
|
||||
#endif
|
||||
jmp *%eax /* jump into loop */
|
||||
ALIGN (3)
|
||||
Loop: movl (%esi),%eax
|
||||
sbbl (%edx),%eax
|
||||
movl %eax,(%edi)
|
||||
movl 4(%esi),%eax
|
||||
sbbl 4(%edx),%eax
|
||||
movl %eax,4(%edi)
|
||||
movl 8(%esi),%eax
|
||||
sbbl 8(%edx),%eax
|
||||
movl %eax,8(%edi)
|
||||
movl 12(%esi),%eax
|
||||
sbbl 12(%edx),%eax
|
||||
movl %eax,12(%edi)
|
||||
movl 16(%esi),%eax
|
||||
sbbl 16(%edx),%eax
|
||||
movl %eax,16(%edi)
|
||||
movl 20(%esi),%eax
|
||||
sbbl 20(%edx),%eax
|
||||
movl %eax,20(%edi)
|
||||
movl 24(%esi),%eax
|
||||
sbbl 24(%edx),%eax
|
||||
movl %eax,24(%edi)
|
||||
movl 28(%esi),%eax
|
||||
sbbl 28(%edx),%eax
|
||||
movl %eax,28(%edi)
|
||||
leal 32(%edi),%edi
|
||||
leal 32(%esi),%esi
|
||||
leal 32(%edx),%edx
|
||||
decl %ecx
|
||||
jnz Loop
|
||||
|
||||
sbbl %eax,%eax
|
||||
negl %eax
|
||||
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
|
68
mpi/i386-openbsd/syntax.h
Normal file
68
mpi/i386-openbsd/syntax.h
Normal file
@ -0,0 +1,68 @@
|
||||
/* syntax.h -- Definitions for x86 syntax variations.
|
||||
*
|
||||
* Copyright (C) 1992, 1994, 1995, 1998,
|
||||
* 2001 Free Software Foundation, Inc.
|
||||
*
|
||||
* GnuPG is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GnuPG is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
* way the data is stored; this is to support the abstraction
|
||||
* of an optional secure memory allocation which may be used
|
||||
* to avoid revealing of sensitive data due to paging etc.
|
||||
* The GNU MP Library itself is published under the LGPL;
|
||||
* however I decided to publish this code under the plain GPL.
|
||||
*/
|
||||
|
||||
#undef ALIGN
|
||||
|
||||
#if defined (BSD_SYNTAX) || defined (ELF_SYNTAX)
|
||||
#define R(r) %r
|
||||
#define MEM(base)(base)
|
||||
#define MEM_DISP(base,displacement)displacement(R(base))
|
||||
#define MEM_INDEX(base,index,size)(R(base),R(index),size)
|
||||
#ifdef __STDC__
|
||||
#define INSN1(mnemonic,size_suffix,dst)mnemonic##size_suffix dst
|
||||
#define INSN2(mnemonic,size_suffix,dst,src)mnemonic##size_suffix src,dst
|
||||
#else
|
||||
#define INSN1(mnemonic,size_suffix,dst)mnemonic/**/size_suffix dst
|
||||
#define INSN2(mnemonic,size_suffix,dst,src)mnemonic/**/size_suffix src,dst
|
||||
#endif
|
||||
#define TEXT .text
|
||||
#if defined (BSD_SYNTAX)
|
||||
#define ALIGN(log) .align log
|
||||
#endif
|
||||
#if defined (ELF_SYNTAX)
|
||||
#define ALIGN(log) .align 1<<(log)
|
||||
#endif
|
||||
#define GLOBL .globl
|
||||
#endif
|
||||
|
||||
#ifdef INTEL_SYNTAX
|
||||
#define R(r) r
|
||||
#define MEM(base)[base]
|
||||
#define MEM_DISP(base,displacement)[base+(displacement)]
|
||||
#define MEM_INDEX(base,index,size)[base+index*size]
|
||||
#define INSN1(mnemonic,size_suffix,dst)mnemonic dst
|
||||
#define INSN2(mnemonic,size_suffix,dst,src)mnemonic dst,src
|
||||
#define TEXT .text
|
||||
#define ALIGN(log) .align log
|
||||
#define GLOBL .globl
|
||||
#endif
|
||||
|
||||
#ifdef X86_BROKEN_ALIGN
|
||||
#undef ALIGN
|
||||
#define ALIGN(log) .align log,0x90
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user