• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500-V1.0.1.40_1.0.68/ap/gpl/timemachine/libgcrypt-1.5.0/mpi/pentium4/sse2/
1/* Intel Pentium-4 mpn_sub_n -- mpn subtraction.
2 *
3 * Copyright 2001, 2002 Free Software Foundation, Inc.
4 *
5 * This file is part of Libgcrypt.
6 *
7 * Libgcrypt is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * Libgcrypt is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20 *
21 * Note: This code is heavily based on the GNU MP Library.
22 *	 Actually it's the same code with only minor changes in the
23 *	 way the data is stored; this is to support the abstraction
24 *	 of an optional secure memory allocation which may be used
25 *	 to avoid revealing of sensitive data due to paging etc.
26 */
27
28
29#include "sysdep.h"
30#include "asm-syntax.h"
31
32
33/*******************
34 *  mpi_limb_t
35 *  _gcry_mpih_sub_n( mpi_ptr_t res_ptr,	(sp + 4)
36 *		   mpi_ptr_t s1_ptr,	(sp + 8)
37 *		   mpi_ptr_t s2_ptr,	(sp + 12)
38 *		   mpi_size_t size)	(sp + 16)
39 *
40 * P4 Willamette, Northwood: 4.0 cycles/limb if dst!=src1 and dst!=src2
41 *			     6.0 cycles/limb if dst==src1 or dst==src2
42 * P4 Prescott:		     >= 5 cycles/limb
43 *
44 * The main loop code is 2x unrolled so that the carry bit can alternate
45 * between mm0 and mm1.
46 */
47
48
49.text
50	ALIGN (3)
51	.globl C_SYMBOL_NAME(_gcry_mpih_sub_n)
52C_SYMBOL_NAME(_gcry_mpih_sub_n:)
53
54	pxor	%mm0, %mm0
55.Lstart_nc:
56	movl	8(%esp), %eax
57	movl	%ebx, 8(%esp)
58	movl	12(%esp), %ebx
59	movl	4(%esp), %edx
60	movl	16(%esp), %ecx
61
62	leal	(%eax,%ecx,4), %eax
63	leal	(%ebx,%ecx,4), %ebx
64	leal	(%edx,%ecx,4), %edx
65	negl	%ecx
66
67.Ltop:
68/*
69	C eax	src1 end
70	C ebx	src2 end
71	C ecx	counter, limbs, negative
72	C edx	dst end
73	C mm0	carry bit
74*/
75
76	movd	(%eax,%ecx,4), %mm1
77	movd	(%ebx,%ecx,4), %mm2
78	psubq	%mm2, %mm1
79
80	psubq	%mm0, %mm1
81	movd	%mm1, (%edx,%ecx,4)
82
83	psrlq	$63, %mm1
84
85	addl	$1, %ecx
86	jz	.Ldone_mm1
87
88	movd	(%eax,%ecx,4), %mm0
89	movd	(%ebx,%ecx,4), %mm2
90	psubq	%mm2, %mm0
91
92	psubq	%mm1, %mm0
93	movd	%mm0, (%edx,%ecx,4)
94
95	psrlq	$63, %mm0
96
97	addl	$1, %ecx
98	jnz	.Ltop
99
100
101	movd	%mm0, %eax
102	movl	8(%esp), %ebx
103	emms
104	ret
105
106
107
108.Ldone_mm1:
109	movd	%mm1, %eax
110	movl	8(%esp), %ebx
111	emms
112	ret
113