Update copyright dates with scripts/update-copyrights.
[glibc.git] / sysdeps / mips / submul_1.S
blobabed351733e47c3bfd9ded51e7f198b97f44a6f1
1 /* MIPS __mpn_submul_1 -- Multiply a limb vector with a single limb and
2 subtract the product from a second limb vector.
4 Copyright (C) 1995-2015 Free Software Foundation, Inc.
6 This file is part of the GNU MP Library.
8 The GNU MP Library is free software; you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or (at your
11 option) any later version.
13 The GNU MP Library is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
16 License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with the GNU MP Library.  If not, see
20 <http://www.gnu.org/licenses/>.  */
22 #include <sysdep.h>
24 /* INPUT PARAMETERS
25    res_ptr      $4
26    s1_ptr       $5
27    size         $6
28    s2_limb      $7
30 #ifdef __PIC__
31         .option pic2
32 #endif
33 ENTRY (__mpn_submul_1)
34         .set    noreorder
35 #ifdef __PIC__
36         .cpload t9
37 #endif
38         .set    nomacro
40         /* warm up phase 0 */
41         lw      $8,0($5)
43         /* warm up phase 1 */
44         addiu   $5,$5,4
45 #if __mips_isa_rev < 6
46         multu   $8,$7
47 #else
48         mulu    $11,$8,$7
49         muhu    $12,$8,$7
50 #endif
52         addiu   $6,$6,-1
53         beq     $6,$0,L(LC0)
54         move    $2,$0           /* zero cy2 */
56         addiu   $6,$6,-1
57         beq     $6,$0,L(LC1)
58         lw      $8,0($5)        /* load new s1 limb as early as possible */
60 L(Loop):        lw      $10,0($4)
61 #if __mips_isa_rev < 6
62         mflo    $3
63         mfhi    $9
64 #else
65         move    $3,$11
66         move    $9,$12
67 #endif
68         addiu   $5,$5,4
69         addu    $3,$3,$2        /* add old carry limb to low product limb */
70 #if __mips_isa_rev < 6
71         multu   $8,$7
72 #else
73         mulu    $11,$8,$7
74         muhu    $12,$8,$7
75 #endif
76         lw      $8,0($5)        /* load new s1 limb as early as possible */
77         addiu   $6,$6,-1        /* decrement loop counter */
78         sltu    $2,$3,$2        /* carry from previous addition -> $2 */
79         subu    $3,$10,$3
80         sgtu    $10,$3,$10
81         addu    $2,$2,$10
82         sw      $3,0($4)
83         addiu   $4,$4,4
84         bne     $6,$0,L(Loop)   /* should be "bnel" */
85         addu    $2,$9,$2        /* add high product limb and carry from addition */
87         /* cool down phase 1 */
88 L(LC1): lw      $10,0($4)
89 #if __mips_isa_rev < 6
90         mflo    $3
91         mfhi    $9
92 #else
93         move    $3,$11
94         move    $9,$12
95 #endif
96         addu    $3,$3,$2
97         sltu    $2,$3,$2
98 #if __mips_isa_rev < 6
99         multu   $8,$7
100 #else
101         mulu    $11,$8,$7
102         muhu    $12,$8,$7
103 #endif
104         subu    $3,$10,$3
105         sgtu    $10,$3,$10
106         addu    $2,$2,$10
107         sw      $3,0($4)
108         addiu   $4,$4,4
109         addu    $2,$9,$2        /* add high product limb and carry from addition */
111         /* cool down phase 0 */
112 L(LC0): lw      $10,0($4)
113 #if __mips_isa_rev < 6
114         mflo    $3
115         mfhi    $9
116 #else
117         move    $3,$11
118         move    $9,$12
119 #endif
120         addu    $3,$3,$2
121         sltu    $2,$3,$2
122         subu    $3,$10,$3
123         sgtu    $10,$3,$10
124         addu    $2,$2,$10
125         sw      $3,0($4)
126         j       $31
127         addu    $2,$9,$2        /* add high product limb and carry from addition */
128         END (__mpn_submul_1)