6ecd53bbcddd9373358a212518bb8f00b1645b16
[ghc-hetmet.git] / ghc / rts / gmp / mpn / powerpc32 / addmul_1.s
1 # PowerPC-32 __mpn_addmul_1 -- Multiply a limb vector with a limb and add
2 # the result to a second limb vector.
3
4 # Copyright (C) 1995 Free Software Foundation, Inc.
5
6 # This file is part of the GNU MP Library.
7
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.
12
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.
17
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.
22
23
24 # INPUT PARAMETERS
25 # res_ptr       r3
26 # s1_ptr        r4
27 # size          r5
28 # s2_limb       r6
29
30 # This is a fairly straightforward implementation.  The timing of the PC601
31 # is hard to understand, so I will wait to optimize this until I have some
32 # hardware to play with.
33
34 # The code trivially generalizes to 64 bit limbs for the PC620.
35
36         .toc
37         .csect .__mpn_addmul_1[PR]
38         .align 2
39         .globl __mpn_addmul_1
40         .globl .__mpn_addmul_1
41         .csect __mpn_addmul_1[DS]
42 __mpn_addmul_1:
43         .long .__mpn_addmul_1[PR], TOC[tc0], 0
44         .csect .__mpn_addmul_1[PR]
45 .__mpn_addmul_1:
46         mtctr   5
47
48         lwz     0,0(4)
49         mullw   7,0,6
50         mulhwu  10,0,6
51         lwz     9,0(3)
52         addc    8,7,9
53         addi    3,3,-4
54         bdz     Lend
55
56 Loop:   lwzu    0,4(4)
57         stwu    8,4(3)
58         mullw   8,0,6
59         adde    7,8,10
60         mulhwu  10,0,6
61         lwz     9,4(3)
62         addze   10,10
63         addc    8,7,9
64         bdnz    Loop
65
66 Lend:   stw     8,4(3)
67         addze   3,10
68         blr