• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/router/libgcrypt-1.5.1/mpi/power/
1/* IBM POWER sub_n -- Subtract two limb vectors of equal, non-zero length.
2 *
3 *      Copyright (C) 1992, 1994, 1995, 1996, 1999,
4 *                    2002 Free Software Foundation, Inc.
5 *
6 * This file is part of Libgcrypt.
7 *
8 * Libgcrypt is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as
10 * published by the Free Software Foundation; either version 2.1 of
11 * the License, or (at your option) any later version.
12 *
13 * Libgcrypt is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
21 */
22
23#include "sysdep.h"
24#include "asm-syntax.h"
25
26/*
27# INPUT PARAMETERS
28# res_ptr	r3
29# s1_ptr	r4
30# s2_ptr	r5
31# size		r6
32 */
33
34	.toc
35	.extern _gcry_mpih_sub_n[DS]
36	.extern ._gcry_mpih_sub_n
37.csect [PR]
38	.align 2
39	.globl _gcry_mpih_sub_n
40	.globl ._gcry_mpih_sub_n
41	.csect _gcry_mpih_sub_n[DS]
42_gcry_mpih_sub_n:
43	.long ._gcry_mpih_sub_n, TOC[tc0], 0
44	.csect [PR]
45._gcry_mpih_sub_n:
46	andil.	10,6,1		# odd or even number of limbs?
47	l	8,0(4)		# load least significant s1 limb
48	l	0,0(5)		# load least significant s2 limb
49	cal	3,-4(3) 	# offset res_ptr, it's updated before it's used
50	sri	10,6,1		# count for unrolled loop
51	sf	7,0,8		# subtract least significant limbs, set cy
52	mtctr	10		# copy count into CTR
53	beq	0,Leven 	# branch if even # of limbs (# of limbs >= 2)
54
55# We have an odd # of limbs.  Add the first limbs separately.
56	cmpi	1,10,0		# is count for unrolled loop zero?
57	bne	1,L1		# branch if not
58	st	7,4(3)
59	sfe	3,0,0		# load !cy into ...
60	sfi	3,3,0		# ... return value register
61	br			# return
62
63# We added least significant limbs.  Now reload the next limbs to enter loop.
64L1:	lu	8,4(4)		# load s1 limb and update s1_ptr
65	lu	0,4(5)		# load s2 limb and update s2_ptr
66	stu	7,4(3)
67	sfe	7,0,8		# subtract limbs, set cy
68Leven:	lu	9,4(4)		# load s1 limb and update s1_ptr
69	lu	10,4(5) 	# load s2 limb and update s2_ptr
70	bdz	Lend		# If done, skip loop
71
72Loop:	lu	8,4(4)		# load s1 limb and update s1_ptr
73	lu	0,4(5)		# load s2 limb and update s2_ptr
74	sfe	11,10,9 	# subtract previous limbs with cy, set cy
75	stu	7,4(3)		#
76	lu	9,4(4)		# load s1 limb and update s1_ptr
77	lu	10,4(5) 	# load s2 limb and update s2_ptr
78	sfe	7,0,8		# subtract previous limbs with cy, set cy
79	stu	11,4(3) 	#
80	bdn	Loop		# decrement CTR and loop back
81
82Lend:	sfe	11,10,9 	# subtract limbs with cy, set cy
83	st	7,4(3)		#
84	st	11,8(3) 	#
85	sfe	3,0,0		# load !cy into ...
86	sfi	3,3,0		# ... return value register
87	br
88
89