1 dnl PowerPC-32 mpn_add_n and mpn_sub_n.
3 dnl Copyright 2002, 2005, 2007 Free Software Foundation, Inc.
5 dnl This file is part of the GNU MP Library.
7 dnl The GNU MP Library is free software; you can redistribute it and/or modify
8 dnl it under the terms of the GNU Lesser General Public License as published
9 dnl by the Free Software Foundation; either version 3 of the License, or (at
10 dnl your option) any later version.
12 dnl The GNU MP Library is distributed in the hope that it will be useful, but
13 dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 dnl License for more details.
17 dnl You should have received a copy of the GNU Lesser General Public License
18 dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
20 include(`../config.m4')
25 C 75x (G3): ? old: 3.5
26 C 7400,7410 (G4): 3.25
28 C power4/ppc970: ? old: 2.0
38 ifdef(`OPERATION_add_n', `
40 define(func, mpn_add_n)
41 define(func_nc, mpn_add_nc)
44 ifdef(`OPERATION_sub_n', `
46 define(func, mpn_sub_n)
47 define(func_nc, mpn_sub_nc)
51 MULFUNC_PROLOGUE(mpn_add_n mpn_add_nc mpn_sub_n mpn_sub_nc)
56 IFADD(` addic r0, cy, -1') C set carry from argument
57 IFSUB(` subfic r0, cy, 0') C set carry from argument
62 IFADD(` addic r0, n, 0') C clear carry
63 IFSUB(` addic r0, n, -1') C set carry
64 L(ent): andi. r0, n, 3
74 lwzx r7, r4, r3 C n = 4, 8, 12, ...
83 L(n00): bge cr7, L(n01)
84 cmpwi cr0, r0, 0 C n = 1, 5, 9, 13, ...
90 L(gt1): lwzx r7, r4, r3
96 lwzx r9, r4, r3 C n = 3, 7, 11, 15, ...
105 L(n01): bne cr7, L(n10)
106 cmpwi cr0, r0, 0 C n = 2, 6, 10, 14, ...
117 L(lp): lwzx r7, r4, r3
121 L(01): lwzx r9, r4, r3
125 L(00): lwzx r11, r4, r3
129 L(11): lwzx r0, r4, r3
135 L(end): ADCSBC r0, r6, r0
137 L(ret): stw r0, 8(r3)
139 IFADD(` addze r3, r3 ')
140 IFSUB(` subfe r3, r0, r0')