[__USE_BSD] (sig_t): New typedef.
[glibc.git] / sysdeps / rs6000 / submul_1.s
blob252633261d011fbbe5e0f20ee3ec952846166beb
1 # IBM POWER __mpn_submul_1 -- Multiply a limb vector with a limb and subtract
2 # the result from a second limb vector.
4 # Copyright (C) 1992, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA.
23 # INPUT PARAMETERS
24 # res_ptr r3
25 # s1_ptr r4
26 # size r5
27 # s2_limb r6
29 # The RS/6000 has no unsigned 32x32->64 bit multiplication instruction. To
30 # obtain that operation, we have to use the 32x32->64 signed multiplication
31 # instruction, and add the appropriate compensation to the high limb of the
32 # result. We add the multiplicand if the multiplier has its most significant
33 # bit set, and we add the multiplier if the multiplicand has its most
34 # significant bit set. We need to preserve the carry flag between each
35 # iteration, so we have to compute the compensation carefully (the natural,
36 # srai+and doesn't work). Since the POWER architecture has a branch unit
37 # we can branch in zero cycles, so that's how we perform the additions.
39 .toc
40 .csect .__mpn_submul_1[PR]
41 .align 2
42 .globl __mpn_submul_1
43 .globl .__mpn_submul_1
44 .csect __mpn_submul_1[DS]
45 __mpn_submul_1:
46 .long .__mpn_submul_1[PR], TOC[tc0], 0
47 .csect .__mpn_submul_1[PR]
48 .__mpn_submul_1:
50 cal 3,-4(3)
51 l 0,0(4)
52 cmpi 0,6,0
53 mtctr 5
54 mul 9,0,6
55 srai 7,0,31
56 and 7,7,6
57 mfmq 11
58 cax 9,9,7
59 l 7,4(3)
60 sf 8,11,7 # add res_limb
61 a 11,8,11 # invert cy (r11 is junk)
62 blt Lneg
63 Lpos: bdz Lend
65 Lploop: lu 0,4(4)
66 stu 8,4(3)
67 cmpi 0,0,0
68 mul 10,0,6
69 mfmq 0
70 ae 11,0,9 # low limb + old_cy_limb + old cy
71 l 7,4(3)
72 aze 10,10 # propagate cy to new cy_limb
73 sf 8,11,7 # add res_limb
74 a 11,8,11 # invert cy (r11 is junk)
75 bge Lp0
76 cax 10,10,6 # adjust high limb for negative limb from s1
77 Lp0: bdz Lend0
78 lu 0,4(4)
79 stu 8,4(3)
80 cmpi 0,0,0
81 mul 9,0,6
82 mfmq 0
83 ae 11,0,10
84 l 7,4(3)
85 aze 9,9
86 sf 8,11,7
87 a 11,8,11 # invert cy (r11 is junk)
88 bge Lp1
89 cax 9,9,6 # adjust high limb for negative limb from s1
90 Lp1: bdn Lploop
92 b Lend
94 Lneg: cax 9,9,0
95 bdz Lend
96 Lnloop: lu 0,4(4)
97 stu 8,4(3)
98 cmpi 0,0,0
99 mul 10,0,6
100 mfmq 7
101 ae 11,7,9
102 l 7,4(3)
103 ae 10,10,0 # propagate cy to new cy_limb
104 sf 8,11,7 # add res_limb
105 a 11,8,11 # invert cy (r11 is junk)
106 bge Ln0
107 cax 10,10,6 # adjust high limb for negative limb from s1
108 Ln0: bdz Lend0
109 lu 0,4(4)
110 stu 8,4(3)
111 cmpi 0,0,0
112 mul 9,0,6
113 mfmq 7
114 ae 11,7,10
115 l 7,4(3)
116 ae 9,9,0 # propagate cy to new cy_limb
117 sf 8,11,7 # add res_limb
118 a 11,8,11 # invert cy (r11 is junk)
119 bge Ln1
120 cax 9,9,6 # adjust high limb for negative limb from s1
121 Ln1: bdn Lnloop
122 b Lend
124 Lend0: cal 9,0(10)
125 Lend: st 8,4(3)
126 aze 3,9