[project @ 2000-08-21 14:16:57 by simonmar]
[ghc-hetmet.git] / ghc / rts / gmp / mpn / sparc64 / sub_n.s
1 ! SPARC v9 __mpn_sub_n -- Subtract two limb vectors of the same length > 0 and
2 ! store difference in a third limb vector.
3
4 ! Copyright (C) 1995, 1996 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       %o0
26 ! s1_ptr        %o1
27 ! s2_ptr        %o2
28 ! size          %o3
29
30 .section        ".text"
31         .align 4
32         .global __mpn_sub_n
33         .type    __mpn_sub_n,#function
34         .proc   04
35 __mpn_sub_n:
36         sub %g0,%o3,%g3
37         sllx %o3,3,%g1
38         add %o1,%g1,%o1                 ! make s1_ptr point at end
39         add %o2,%g1,%o2                 ! make s2_ptr point at end
40         add %o0,%g1,%o0                 ! make res_ptr point at end
41         mov 0,%o4                       ! clear carry variable
42         sllx %g3,3,%o5                  ! compute initial address index
43
44 .Loop:  ldx [%o2+%o5],%g1               ! load s2 limb
45         add %g3,1,%g3                   ! increment loop count
46         ldx [%o1+%o5],%g2               ! load s1 limb
47         addcc %g1,%o4,%g1               ! add s2 limb and carry variable
48         movcc %xcc,0,%o4                ! if carry-out, o4 was 1; clear it
49         subcc %g1,%g2,%g1               ! subtract s1 limb from sum
50         stx %g1,[%o0+%o5]               ! store result
51         add %o5,8,%o5                   ! increment address index
52         brnz,pt %g3,.Loop
53         movcs %xcc,1,%o4                ! if s1 subtract gave carry, record it
54
55         retl
56         mov %o4,%o0
57 .LLfe1:
58         .size    __mpn_sub_n,.LLfe1-__mpn_sub_n