Update copyright notices with scripts/update-copyrights
[glibc.git] / sysdeps / sparc / sparc64 / sub_n.S
blob2ddfddb47645e5155e81acacfe319dc9a53f585b
1 /* SPARC v9 __mpn_sub_n -- Subtract two limb vectors of the same length > 0
2    and store difference in a third limb vector.
4    Copyright (C) 1995-2014 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 Lesser General Public License as published by
10    the Free Software Foundation; either version 2.1 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 Lesser General Public
16    License for more details.
18    You should have received a copy of the GNU Lesser General Public License
19    along with the GNU MP Library; see the file COPYING.LIB.  If not,
20    see <http://www.gnu.org/licenses/>.  */
22 #include <sysdep.h>
24 /* INPUT PARAMETERS
25    res_ptr      %o0
26    s1_ptr       %o1
27    s2_ptr       %o2
28    size         %o3  */
30 ENTRY(__mpn_sub_n)
32         sub %g0,%o3,%g5
33         sllx %o3,3,%g1
34         add %o1,%g1,%o1                 ! make s1_ptr point at end
35         add %o2,%g1,%o2                 ! make s2_ptr point at end
36         add %o0,%g1,%o0                 ! make res_ptr point at end
37         mov 0,%o4                       ! clear carry variable
38         sllx %g5,3,%o5                  ! compute initial address index
40 1:      ldx [%o2+%o5],%g1               ! load s2 limb
41         add %g5,1,%g5                   ! increment loop count
42         ldx [%o1+%o5],%o3               ! load s1 limb
43         addcc %g1,%o4,%g1               ! add s2 limb and carry variable
44         movcc %xcc,0,%o4                ! if carry-out, o4 was 1; clear it
45         subcc %o3,%g1,%g1               ! subtract s1 limb from sum
46         stx %g1,[%o0+%o5]               ! store result
47         add %o5,8,%o5                   ! increment address index
48         brnz,pt %g5,1b
49          movcs %xcc,1,%o4               ! if s1 subtract gave carry, record it
51         retl
52          mov %o4,%o0
54 END(__mpn_sub_n)