Tizen 2.1 base
[external/gmp.git] / mpn / mips32 / mul_1.asm
1 dnl  MIPS32 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, 1996, 2000, 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 size          $6
27 C s2_limb       $7
28
29 ASM_START()
30 PROLOGUE(mpn_mul_1)
31
32 C feed-in phase 0
33         lw      $8,0($5)
34
35 C feed-in phase 1
36         addiu   $5,$5,4
37         multu   $8,$7
38
39         addiu   $6,$6,-1
40         beq     $6,$0,$LC0
41          move   $2,$0           C zero cy2
42
43         addiu   $6,$6,-1
44         beq     $6,$0,$LC1
45         lw      $8,0($5)        C load new s1 limb as early as possible
46
47 Loop:   mflo    $10
48         mfhi    $9
49         addiu   $5,$5,4
50         addu    $10,$10,$2      C add old carry limb to low product limb
51         multu   $8,$7
52         lw      $8,0($5)        C load new s1 limb as early as possible
53         addiu   $6,$6,-1        C decrement loop counter
54         sltu    $2,$10,$2       C carry from previous addition -> $2
55         sw      $10,0($4)
56         addiu   $4,$4,4
57         bne     $6,$0,Loop
58          addu   $2,$9,$2        C add high product limb and carry from addition
59
60 C wind-down phase 1
61 $LC1:   mflo    $10
62         mfhi    $9
63         addu    $10,$10,$2
64         sltu    $2,$10,$2
65         multu   $8,$7
66         sw      $10,0($4)
67         addiu   $4,$4,4
68         addu    $2,$9,$2        C add high product limb and carry from addition
69
70 C wind-down phase 0
71 $LC0:   mflo    $10
72         mfhi    $9
73         addu    $10,$10,$2
74         sltu    $2,$10,$2
75         sw      $10,0($4)
76         j       $31
77         addu    $2,$9,$2        C add high product limb and carry from addition
78 EPILOGUE(mpn_mul_1)