dc13cac0da8d7ff2b6c1494bc0f9bdd87a5642ec
[ghc-hetmet.git] / ghc / rts / gmp / mpn / powerpc32 / mul_1.s
1 # PowerPC-32 __mpn_mul_1 -- Multiply a limb vector with a limb and store
2 # the result in a second limb vector.
3
4 # Copyright (C) 1993, 1994, 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_mul_1[PR]
38         .align 2
39         .globl __mpn_mul_1
40         .globl .__mpn_mul_1
41         .csect __mpn_mul_1[DS]
42 __mpn_mul_1:
43         .long .__mpn_mul_1[PR], TOC[tc0], 0
44         .csect .__mpn_mul_1[PR]
45 .__mpn_mul_1:
46         mtctr   5
47
48         lwz     0,0(4)
49         mullw   7,0,6
50         mulhwu  10,0,6
51         addi    3,3,-4          # adjust res_ptr
52         addic   5,5,0           # clear cy with dummy insn
53         bdz     Lend
54
55 Loop:   lwzu    0,4(4)
56         stwu    7,4(3)
57         mullw   8,0,6
58         adde    7,8,10
59         mulhwu  10,0,6
60         bdnz    Loop
61
62 Lend:   stw     7,4(3)
63         addze   3,10
64         blr