update from main archive 961217
[glibc.git] / sysdeps / mips / mips3 / submul_1.s
bloba9c9fa25149dc52213640ad60b18d0d28c28f24b
1 # MIPS3 __mpn_submul_1 -- Multiply a limb vector with a single limb and
2 # subtract the product from a second limb vector.
4 # Copyright (C) 1992, 1994, 1995 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 Library General Public License as published by
10 # the Free Software Foundation; either version 2 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 Library General Public
16 # License for more details.
18 # You should have received a copy of the GNU Library General Public License
19 # along with the GNU MP Library; see the file COPYING.LIB. If not, write to
20 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21 # MA 02111-1307, USA.
24 # INPUT PARAMETERS
25 # res_ptr $4
26 # s1_ptr $5
27 # size $6
28 # s2_limb $7
30 .text
31 .align 4
32 .globl __mpn_submul_1
33 .ent __mpn_submul_1
34 __mpn_submul_1:
35 .set noreorder
36 .set nomacro
38 # warm up phase 0
39 ld $8,0($5)
41 # warm up phase 1
42 daddiu $5,$5,8
43 dmultu $8,$7
45 daddiu $6,$6,-1
46 beq $6,$0,$LC0
47 move $2,$0 # zero cy2
49 daddiu $6,$6,-1
50 beq $6,$0,$LC1
51 ld $8,0($5) # load new s1 limb as early as possible
53 Loop: ld $10,0($4)
54 mflo $3
55 mfhi $9
56 daddiu $5,$5,8
57 daddu $3,$3,$2 # add old carry limb to low product limb
58 dmultu $8,$7
59 ld $8,0($5) # load new s1 limb as early as possible
60 daddiu $6,$6,-1 # decrement loop counter
61 sltu $2,$3,$2 # carry from previous addition -> $2
62 dsubu $3,$10,$3
63 sgtu $10,$3,$10
64 daddu $2,$2,$10
65 sd $3,0($4)
66 daddiu $4,$4,8
67 bne $6,$0,Loop
68 daddu $2,$9,$2 # add high product limb and carry from addition
70 # cool down phase 1
71 $LC1: ld $10,0($4)
72 mflo $3
73 mfhi $9
74 daddu $3,$3,$2
75 sltu $2,$3,$2
76 dmultu $8,$7
77 dsubu $3,$10,$3
78 sgtu $10,$3,$10
79 daddu $2,$2,$10
80 sd $3,0($4)
81 daddiu $4,$4,8
82 daddu $2,$9,$2 # add high product limb and carry from addition
84 # cool down phase 0
85 $LC0: ld $10,0($4)
86 mflo $3
87 mfhi $9
88 daddu $3,$3,$2
89 sltu $2,$3,$2
90 dsubu $3,$10,$3
91 sgtu $10,$3,$10
92 daddu $2,$2,$10
93 sd $3,0($4)
94 j $31
95 daddu $2,$9,$2 # add high product limb and carry from addition
97 .end __mpn_submul_1