Upload Tizen:Base source
[external/gmp.git] / mpn / mips32 / submul_1.asm
1 dnl  MIPS32 mpn_submul_1 -- Multiply a limb vector with a single limb and
2 dnl  subtract the product from 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_submul_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:   lw      $10,0($4)
48         mflo    $3
49         mfhi    $9
50         addiu   $5,$5,4
51         addu    $3,$3,$2        C add old carry limb to low product limb
52         multu   $8,$7
53         lw      $8,0($5)        C load new s1 limb as early as possible
54         addiu   $6,$6,-1        C decrement loop counter
55         sltu    $2,$3,$2        C carry from previous addition -> $2
56         subu    $3,$10,$3
57         sgtu    $10,$3,$10
58         addu    $2,$2,$10
59         sw      $3,0($4)
60         addiu   $4,$4,4
61         bne     $6,$0,Loop
62          addu   $2,$9,$2        C add high product limb and carry from addition
63
64 C wind-down phase 1
65 $LC1:   lw      $10,0($4)
66         mflo    $3
67         mfhi    $9
68         addu    $3,$3,$2
69         sltu    $2,$3,$2
70         multu   $8,$7
71         subu    $3,$10,$3
72         sgtu    $10,$3,$10
73         addu    $2,$2,$10
74         sw      $3,0($4)
75         addiu   $4,$4,4
76         addu    $2,$9,$2        C add high product limb and carry from addition
77
78 C wind-down phase 0
79 $LC0:   lw      $10,0($4)
80         mflo    $3
81         mfhi    $9
82         addu    $3,$3,$2
83         sltu    $2,$3,$2
84         subu    $3,$10,$3
85         sgtu    $10,$3,$10
86         addu    $2,$2,$10
87         sw      $3,0($4)
88         j       $31
89         addu    $2,$9,$2        C add high product limb and carry from addition
90 EPILOGUE(mpn_submul_1)