• 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/alpha/
1/* Alpha 21064 mpih-mul1.S -- Multiply a limb vector with a limb and store
2 *			      the result in a second limb vector.
3 *
4 *      Copyright (C) 1992, 1994, 1995, 1998,
5 *                    2001, 2002 Free Software Foundation, Inc.
6 *
7 * This file is part of Libgcrypt.
8 *
9 * Libgcrypt is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as
11 * published by the Free Software Foundation; either version 2.1 of
12 * the License, or (at your option) any later version.
13 *
14 * Libgcrypt is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
22 */
23
24
25/*******************
26 * mpi_limb_t
27 * _gcry_mpih_mul_1( mpi_ptr_t res_ptr,	(r16)
28 *		  mpi_ptr_t s1_ptr,	(r17)
29 *		  mpi_size_t s1_size,	(r18)
30 *		  mpi_limb_t s2_limb)	(r19)
31 *
32 * This code runs at 42 cycles/limb on the EV4 and 18 cycles/limb on the EV5.
33 *
34 * To improve performance for long multiplications, we would use
35 * 'fetch' for S1 and 'fetch_m' for RES.  It's not obvious how to use
36 * these instructions without slowing down the general code: 1. We can
37 * only have two prefetches in operation at any time in the Alpha
38 * architecture.  2. There will seldom be any special alignment
39 * between RES_PTR and S1_PTR.	Maybe we can simply divide the current
40 * loop into an inner and outer loop, having the inner loop handle
41 * exactly one prefetch block?
42 */
43
44	.set	noreorder
45	.set	noat
46.text
47	.align	3
48	.globl	_gcry_mpih_mul_1
49	.ent	_gcry_mpih_mul_1 2
50_gcry_mpih_mul_1:
51	.frame	$30,0,$26
52
53	ldq	$2,0($17)	# $2 = s1_limb
54	subq	$18,1,$18	# size--
55	mulq	$2,$19,$3	# $3 = prod_low
56	bic	$31,$31,$4	# clear cy_limb
57	umulh	$2,$19,$0	# $0 = prod_high
58	beq	$18,Lend1	# jump if size was == 1
59	ldq	$2,8($17)	# $2 = s1_limb
60	subq	$18,1,$18	# size--
61	stq	$3,0($16)
62	beq	$18,Lend2	# jump if size was == 2
63
64	.align	3
65Loop:	mulq	$2,$19,$3	# $3 = prod_low
66	addq	$4,$0,$0	# cy_limb = cy_limb + 'cy'
67	subq	$18,1,$18	# size--
68	umulh	$2,$19,$4	# $4 = cy_limb
69	ldq	$2,16($17)	# $2 = s1_limb
70	addq	$17,8,$17	# s1_ptr++
71	addq	$3,$0,$3	# $3 = cy_limb + prod_low
72	stq	$3,8($16)
73	cmpult	$3,$0,$0	# $0 = carry from (cy_limb + prod_low)
74	addq	$16,8,$16	# res_ptr++
75	bne	$18,Loop
76
77Lend2:	mulq	$2,$19,$3	# $3 = prod_low
78	addq	$4,$0,$0	# cy_limb = cy_limb + 'cy'
79	umulh	$2,$19,$4	# $4 = cy_limb
80	addq	$3,$0,$3	# $3 = cy_limb + prod_low
81	cmpult	$3,$0,$0	# $0 = carry from (cy_limb + prod_low)
82	stq	$3,8($16)
83	addq	$4,$0,$0	# cy_limb = prod_high + cy
84	ret	$31,($26),1
85Lend1:	stq	$3,0($16)
86	ret	$31,($26),1
87
88	.end	_gcry_mpih_mul_1
89
90
91