1dnl  PowerPC-64/mode32 mpn_sub_n -- Subtract two limb vectors of the same
2dnl  length and store difference in a third limb vector.
3
4dnl  Copyright 1999-2001, 2003, 2005 Free Software Foundation, Inc.
5
6dnl  This file is part of the GNU MP Library.
7dnl
8dnl  The GNU MP Library is free software; you can redistribute it and/or modify
9dnl  it under the terms of either:
10dnl
11dnl    * the GNU Lesser General Public License as published by the Free
12dnl      Software Foundation; either version 3 of the License, or (at your
13dnl      option) any later version.
14dnl
15dnl  or
16dnl
17dnl    * the GNU General Public License as published by the Free Software
18dnl      Foundation; either version 2 of the License, or (at your option) any
19dnl      later version.
20dnl
21dnl  or both in parallel, as here.
22dnl
23dnl  The GNU MP Library is distributed in the hope that it will be useful, but
24dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
25dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
26dnl  for more details.
27dnl
28dnl  You should have received copies of the GNU General Public License and the
29dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
30dnl  see https://www.gnu.org/licenses/.
31
32include(`../config.m4')
33
34C                   cycles/limb
35C POWER3/PPC630:     ?
36C POWER4/PPC970:     4.25
37
38C INPUT PARAMETERS
39C rp      r3
40C up      r4
41C vp      r5
42C n       r6
43
44ASM_START()
45PROLOGUE(mpn_sub_n)
46          mtctr     r6                  C copy size into CTR
47          addic     r0, r6, -1          C set cy
48          ld        r8, 0(r4) C load least significant s1 limb
49          ld        r0, 0(r5) C load least significant s2 limb
50          addi      r3, r3, -8          C offset res_ptr, it's updated before it's used
51          bdz       L(end)              C If done, skip loop
52
53L(oop):   ld        r9, 8(r4) C load s1 limb
54          ld        r10, 8(r5)          C load s2 limb
55          subfe     r7, r0, r8          C subtract limbs with cy, set cy
56          srdi      r6, r0, 32
57          srdi      r11, r8, 32
58          subfe     r6, r6, r11
59          std       r7, 8(r3) C store result limb
60          bdz       L(exit)             C decrement CTR and exit if done
61          ldu       r8, 16(r4)          C load s1 limb and update s1_ptr
62          ldu       r0, 16(r5)          C load s2 limb and update s2_ptr
63          subfe     r7, r10, r9         C subtract limbs with cy, set cy
64          srdi      r6, r10, 32
65          srdi      r11, r9, 32
66          subfe     r6, r6, r11
67          stdu      r7, 16(r3)          C store result limb and update res_ptr
68          bdnz      L(oop)              C decrement CTR and loop back
69
70L(end):   subfe     r7, r0, r8
71          srdi      r6, r0, 32
72          srdi      r11, r8, 32
73          subfe     r6, r6, r11
74          std       r7, 8(r3) C store ultimate result limb
75          subfe     r3, r0, r0          C load !cy into ...
76          subfic    r4, r3, 0 C ... return value register
77          li        r3, 0               C zero extend return value
78          blr
79L(exit):  subfe     r7, r10, r9
80          srdi      r6, r10, 32
81          srdi      r11, r9, 32
82          subfe     r6, r6, r11
83          std       r7, 16(r3)
84          subfe     r3, r0, r0          C load !cy into ...
85          subfic    r4, r3, 0 C ... return value register
86          li        r3, 0               C zero extend return value
87          blr
88EPILOGUE()
89