[project @ 2000-08-21 14:16:57 by simonmar]
[ghc-hetmet.git] / ghc / rts / gmp / mpn / powerpc32 / sub_n.s
1 # PowerPC-32  __mpn_sub_n -- Subtract two limb vectors of the same length > 0
2 # and store difference in a third limb vector.
3
4 # Copyright (C) 1992, 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 # s2_ptr        r5
28 # size          r6
29
30         .toc
31         .extern __mpn_sub_n[DS]
32         .extern .__mpn_sub_n
33 .csect [PR]
34         .align 2
35         .globl __mpn_sub_n
36         .globl .__mpn_sub_n
37         .csect __mpn_sub_n[DS]
38 __mpn_sub_n:
39         .long .__mpn_sub_n, TOC[tc0], 0
40         .csect [PR]
41 .__mpn_sub_n:
42         mtctr   6               # copy size into CTR
43         lwz     8,0(4)          # load least significant s1 limb
44         lwz     0,0(5)          # load least significant s2 limb
45         addi    3,3,-4          # offset res_ptr, it's updated before used
46         subfc   7,0,8           # add least significant limbs, set cy
47         bdz     Lend            # If done, skip loop
48 Loop:   lwzu    8,4(4)          # load s1 limb and update s1_ptr
49         lwzu    0,4(5)          # load s2 limb and update s2_ptr
50         stwu    7,4(3)          # store previous limb in load latency slot
51         subfe   7,0,8           # add new limbs with cy, set cy
52         bdnz    Loop            # decrement CTR and loop back
53 Lend:   stw     7,4(3)          # store ultimate result limb
54         subfe   3,0,0           # load !cy into ...
55         subfic  3,3,0           # ... return value register
56         blr