Upload Tizen:Base source
[external/gmp.git] / mpn / mips64 / mul_1.asm
1 dnl  MIPS64 mpn_mul_1 -- Multiply a limb vector with a single limb and store
2 dnl  the product in 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_mul_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:   nop
49         mflo    $10
50         mfhi    $9
51         daddiu  $5,$5,8
52         daddu   $10,$10,$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,$10,$2       C carry from previous addition -> $2
57         nop
58         nop
59         sd      $10,0($4)
60         daddiu  $4,$4,8
61         bne     $6,$0,Loop
62          daddu  $2,$9,$2        C add high product limb and carry from addition
63
64 C wind-down phase 1
65 $LC1:   mflo    $10
66         mfhi    $9
67         daddu   $10,$10,$2
68         sltu    $2,$10,$2
69         dmultu  $8,$7
70         sd      $10,0($4)
71         daddiu  $4,$4,8
72         daddu   $2,$9,$2        C add high product limb and carry from addition
73
74 C wind-down phase 0
75 $LC0:   mflo    $10
76         mfhi    $9
77         daddu   $10,$10,$2
78         sltu    $2,$10,$2
79         sd      $10,0($4)
80         j       $31
81         daddu   $2,$9,$2        C add high product limb and carry from addition
82 EPILOGUE(mpn_mul_1)