• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/ap/gpl/timemachine/libgcrypt-1.5.0/mpi/powerpc32/
1/* PowerPC-32 rshift
2 *
3 *      Copyright (C) 1995, 1998, 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
22
23#include "sysdep.h"
24#include "asm-syntax.h"
25
26
27#ifndef USE_PPC_PATCHES
28
29/*******************
30 * mpi_limb_t
31 * _gcry_mpih_rshift( mpi_ptr_t wp,	(r3)
32 *		   mpi_ptr_t up,	(r4)
33 *		   mpi_size_t usize,	(r5)
34 *		   unsigned cnt)	(r6)
35 */
36
37	.toc
38.csect	.text[PR]
39	.align	2
40	.globl	_gcry_mpih_rshift
41	.globl	._gcry_mpih_rshift
42	.csect	_gcry_mpih_rshift[DS]
43_gcry_mpih_rshift:
44	.long	._gcry_mpih_rshift,  TOC[tc0],	  0
45	.csect	.text[PR]
46._gcry_mpih_rshift:
47	mtctr	5		# copy size into CTR
48	addi	7,3,-4		# move adjusted res_ptr to free return reg
49	subfic	8,6,32
50	lwz	11,0(4) 	# load first s1 limb
51	slw	3,11,8		# compute function return value
52	bdz	Lend1
53
54Loop:	lwzu	10,4(4)
55	srw	9,11,6
56	slw	12,10,8
57	or	9,9,12
58	stwu	9,4(7)
59	bdz	Lend2
60	lwzu	11,4(4)
61	srw	9,10,6
62	slw	12,11,8
63	or	9,9,12
64	stwu	9,4(7)
65	bdnz	Loop
66
67Lend1:	srw	0,11,6
68	stw	0,4(7)
69	blr
70
71Lend2:	srw	0,10,6
72	stw	0,4(7)
73	blr
74
75#else
76/* Shift a limb right, low level routine.
77   Copyright (C) 1995, 1997 Free Software Foundation, Inc.
78   This file is part of the GNU C Library.
79
80   The GNU C Library is free software; you can redistribute it and/or
81   modify it under the terms of the GNU Library General Public License as
82   published by the Free Software Foundation; either version 2 of the
83   License, or (at your option) any later version.
84
85   The GNU C Library is distributed in the hope that it will be useful,
86   but WITHOUT ANY WARRANTY; without even the implied warranty of
87   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
88   Library General Public License for more details.
89
90   You should have received a copy of the GNU Library General Public
91   License along with the GNU C Library; see the file COPYING.LIB.  If not,
92   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
93   Boston, MA 02111-1307, USA.	*/
94
95
96/* INPUT PARAMETERS
97   res_ptr     r3
98   s1_ptr      r4
99   size 	       r5
100   cnt	       r6  */
101
102ENTRY(_gcry_mpih_rshift)
103       mtctr   5	       # copy size into CTR
104       addi    7,3,-4	       # move adjusted res_ptr to free return reg
105       subfic  8,6,32
106       lwz     11,0(4)	       # load first s1 limb
107       slw     3,11,8	       # compute function return value
108       bdz     1f
109
1100:     lwzu    10,4(4)
111       srw     9,11,6
112       slw     12,10,8
113       or      9,9,12
114       stwu    9,4(7)
115       bdz     2f
116       lwzu    11,4(4)
117       srw     9,10,6
118       slw     12,11,8
119       or      9,9,12
120       stwu    9,4(7)
121       bdnz    0b
122
1231:     srw     0,11,6
124       stw     0,4(7)
125       blr
126
1272:     srw     0,10,6
128       stw     0,4(7)
129       blr
130END(_gcry_mpih_rshift)
131#endif
132