Upload Tizen:Base source
[external/gmp.git] / mpn / mips64 / add_n.asm
1 dnl  MIPS64 mpn_add_n -- Add two limb vectors of the same length > 0 and store
2 dnl  sum in a third limb vector.
3
4 dnl  Copyright 1995, 2000, 2001, 2002 Free Software Foundation, Inc.
5
6 dnl  This file is part of the GNU MP Library.
7
8 dnl  The GNU MP Library is free software; you can redistribute it and/or modify
9 dnl  it under the terms of the GNU Lesser General Public License as published
10 dnl  by the Free Software Foundation; either version 3 of the License, or (at
11 dnl  your option) any later version.
12
13 dnl  The GNU MP Library is distributed in the hope that it will be useful, but
14 dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
16 dnl  License for more details.
17
18 dnl  You should have received a copy of the GNU Lesser General Public License
19 dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
20
21 include(`../config.m4')
22
23 C INPUT PARAMETERS
24 C res_ptr       $4
25 C s1_ptr        $5
26 C s2_ptr        $6
27 C size          $7
28
29 ASM_START()
30 PROLOGUE(mpn_add_n)
31         ld      $10,0($5)
32         ld      $11,0($6)
33
34         daddiu  $7,$7,-1
35         and     $9,$7,4-1       C number of limbs in first loop
36         beq     $9,$0,.L0       C if multiple of 4 limbs, skip first loop
37          move   $2,$0
38
39         dsubu   $7,$7,$9
40
41 .Loop0: daddiu  $9,$9,-1
42         ld      $12,8($5)
43         daddu   $11,$11,$2
44         ld      $13,8($6)
45         sltu    $8,$11,$2
46         daddu   $11,$10,$11
47         sltu    $2,$11,$10
48         sd      $11,0($4)
49         or      $2,$2,$8
50
51         daddiu  $5,$5,8
52         daddiu  $6,$6,8
53         move    $10,$12
54         move    $11,$13
55         bne     $9,$0,.Loop0
56          daddiu $4,$4,8
57
58 .L0:    beq     $7,$0,.Lend
59          nop
60
61 .Loop:  daddiu  $7,$7,-4
62
63         ld      $12,8($5)
64         daddu   $11,$11,$10
65         ld      $13,8($6)
66         sltu    $8,$11,$10
67         daddu   $11,$11,$2
68         sltu    $2,$11,$2
69         sd      $11,0($4)
70         or      $2,$2,$8
71
72         ld      $10,16($5)
73         daddu   $13,$13,$12
74         ld      $11,16($6)
75         sltu    $8,$13,$12
76         daddu   $13,$13,$2
77         sltu    $2,$13,$2
78         sd      $13,8($4)
79         or      $2,$2,$8
80
81         ld      $12,24($5)
82         daddu   $11,$11,$10
83         ld      $13,24($6)
84         sltu    $8,$11,$10
85         daddu   $11,$11,$2
86         sltu    $2,$11,$2
87         sd      $11,16($4)
88         or      $2,$2,$8
89
90         ld      $10,32($5)
91         daddu   $13,$13,$12
92         ld      $11,32($6)
93         sltu    $8,$13,$12
94         daddu   $13,$13,$2
95         sltu    $2,$13,$2
96         sd      $13,24($4)
97         or      $2,$2,$8
98
99         daddiu  $5,$5,32
100         daddiu  $6,$6,32
101
102         bne     $7,$0,.Loop
103          daddiu $4,$4,32
104
105 .Lend:  daddu   $11,$11,$2
106         sltu    $8,$11,$2
107         daddu   $11,$10,$11
108         sltu    $2,$11,$10
109         sd      $11,0($4)
110         j       $31
111         or      $2,$2,$8
112 EPILOGUE(mpn_add_n)