Upload Tizen:Base source
[external/gmp.git] / mpn / alpha / sqr_diagonal.asm
1 dnl  Alpha mpn_sqr_diagonal.
2
3 dnl  Copyright 2001, 2002 Free Software Foundation, Inc.
4
5 dnl  This file is part of the GNU MP Library.
6
7 dnl  The GNU MP Library is free software; you can redistribute it and/or modify
8 dnl  it under the terms of the GNU Lesser General Public License as published
9 dnl  by the Free Software Foundation; either version 3 of the License, or (at
10 dnl  your option) any later version.
11
12 dnl  The GNU MP Library is distributed in the hope that it will be useful, but
13 dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
15 dnl  License for more details.
16
17 dnl  You should have received a copy of the GNU Lesser General Public License
18 dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
19
20 include(`../config.m4')
21
22 C      cycles/limb
23 C EV4:     42
24 C EV5:     18
25 C EV6:      3.45
26
27 C  INPUT PARAMETERS
28 C  rp   r16
29 C  up   r17
30 C  n    r18
31
32
33 ASM_START()
34 PROLOGUE(mpn_sqr_diagonal)
35         ldq     r2,0(r17)       C r2 = s1_limb
36         lda     r18,-2(r18)     C size -= 2
37         mulq    r2,r2,r3        C r3 = prod_low
38         umulh   r2,r2,r4        C r4 = prod_high
39         blt     r18,$Lend1      C jump if size was == 1
40         ldq     r2,8(r17)       C r2 = s1_limb
41         beq     r18,$Lend2      C jump if size was == 2
42
43         ALIGN(8)
44 $Loop:  stq     r3,0(r16)
45         mulq    r2,r2,r3        C r3 = prod_low
46         lda     r18,-1(r18)     C size--
47         stq     r4,8(r16)
48         umulh   r2,r2,r4        C r4 = cy_limb
49         ldq     r2,16(r17)      C r2 = s1_limb
50         lda     r17,8(r17)      C s1_ptr++
51         lda     r16,16(r16)     C res_ptr++
52         bne     r18,$Loop
53
54 $Lend2: stq     r3,0(r16)
55         mulq    r2,r2,r3        C r3 = prod_low
56         stq     r4,8(r16)
57         umulh   r2,r2,r4        C r4 = cy_limb
58         stq     r3,16(r16)
59         stq     r4,24(r16)
60         ret     r31,(r26),1
61 $Lend1: stq     r3,0(r16)
62         stq     r4,8(r16)
63         ret     r31,(r26),1
64 EPILOGUE(mpn_sqr_diagonal)
65 ASM_END()