Upload Tizen:Base source
[external/gmp.git] / mpn / mips64 / addmul_1.asm
1 dnl  MIPS64 mpn_addmul_1 -- Multiply a limb vector with a single limb and add
2 dnl  the product to a second limb vector.
3
4 dnl  Copyright 1992, 1994, 1995, 2000, 2001, 2002 Free Software Foundation,
5 dnl  Inc.
6
7 dnl  This file is part of the GNU MP Library.
8
9 dnl  The GNU MP Library is free software; you can redistribute it and/or modify
10 dnl  it under the terms of the GNU Lesser General Public License as published
11 dnl  by the Free Software Foundation; either version 3 of the License, or (at
12 dnl  your option) any later version.
13
14 dnl  The GNU MP Library is distributed in the hope that it will be useful, but
15 dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
17 dnl  License for more details.
18
19 dnl  You should have received a copy of the GNU Lesser General Public License
20 dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
21
22 include(`../config.m4')
23
24 C INPUT PARAMETERS
25 C res_ptr       $4
26 C s1_ptr        $5
27 C size          $6
28 C s2_limb       $7
29
30 ASM_START()
31 PROLOGUE(mpn_addmul_1)
32
33 C feed-in phase 0
34         ld      $8,0($5)
35
36 C feed-in phase 1
37         daddiu  $5,$5,8
38         dmultu  $8,$7
39
40         daddiu  $6,$6,-1
41         beq     $6,$0,$LC0
42          move   $2,$0           C zero cy2
43
44         daddiu  $6,$6,-1
45         beq     $6,$0,$LC1
46         ld      $8,0($5)        C load new s1 limb as early as possible
47
48 Loop:   ld      $10,0($4)
49         mflo    $3
50         mfhi    $9
51         daddiu  $5,$5,8
52         daddu   $3,$3,$2        C add old carry limb to low product limb
53         dmultu  $8,$7
54         ld      $8,0($5)        C load new s1 limb as early as possible
55         daddiu  $6,$6,-1        C decrement loop counter
56         sltu    $2,$3,$2        C carry from previous addition -> $2
57         daddu   $3,$10,$3
58         sltu    $10,$3,$10
59         daddu   $2,$2,$10
60         sd      $3,0($4)
61         daddiu  $4,$4,8
62         bne     $6,$0,Loop
63          daddu  $2,$9,$2        C add high product limb and carry from addition
64
65 C wind-down phase 1
66 $LC1:   ld      $10,0($4)
67         mflo    $3
68         mfhi    $9
69         daddu   $3,$3,$2
70         sltu    $2,$3,$2
71         dmultu  $8,$7
72         daddu   $3,$10,$3
73         sltu    $10,$3,$10
74         daddu   $2,$2,$10
75         sd      $3,0($4)
76         daddiu  $4,$4,8
77         daddu   $2,$9,$2        C add high product limb and carry from addition
78
79 C wind-down phase 0
80 $LC0:   ld      $10,0($4)
81         mflo    $3
82         mfhi    $9
83         daddu   $3,$3,$2
84         sltu    $2,$3,$2
85         daddu   $3,$10,$3
86         sltu    $10,$3,$10
87         daddu   $2,$2,$10
88         sd      $3,0($4)
89         j       $31
90         daddu   $2,$9,$2        C add high product limb and carry from addition
91 EPILOGUE(mpn_addmul_1)