1
/* PowerPC-32 sub_n -- Subtract two limb vectors of the same length > 0
2
* and store difference in a third limb vector.
4
* Copyright (C) 1992, 1994, 1995, 1998 Free Software Foundation, Inc.
6
* This file is part of GnuPG.
8
* GnuPG is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
11
* (at your option) any later version.
13
* GnuPG is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program; if not, write to the Free Software
20
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
24
#include "asm-syntax.h"
27
#ifndef USE_PPC_PATCHES
31
* mpihelp_sub_n( mpi_ptr_t res_ptr, (r3)
32
* mpi_ptr_t s1_ptr, (r4)
33
* mpi_ptr_t s2_ptr, (r5)
34
* mpi_size_t size) (r6)
38
.extern mpihelp_sub_n[DS]
39
.extern .mpihelp_sub_n
44
.csect mpihelp_sub_n[DS]
46
.long .mpihelp_sub_n, TOC[tc0], 0
49
mtctr 6 # copy size into CTR
50
lwz 8,0(4) # load least significant s1 limb
51
lwz 0,0(5) # load least significant s2 limb
52
addi 3,3,-4 # offset res_ptr, it is updated before used
53
subfc 7,0,8 # add least significant limbs, set cy
54
bdz Lend # If done, skip loop
55
Loop: lwzu 8,4(4) # load s1 limb and update s1_ptr
56
lwzu 0,4(5) # load s2 limb and update s2_ptr
57
stwu 7,4(3) # store previous limb in load latency slot
58
subfe 7,0,8 # add new limbs with cy, set cy
59
bdnz Loop # decrement CTR and loop back
60
Lend: stw 7,4(3) # store ultimate result limb
61
subfe 3,0,0 # load !cy into ...
62
subfic 3,3,0 # ... return value register
66
/* Subtract two limb vectors of equal, non-zero length for PowerPC.
67
Copyright (C) 1997 Free Software Foundation, Inc.
68
This file is part of the GNU C Library.
70
The GNU C Library is free software; you can redistribute it and/or
71
modify it under the terms of the GNU Library General Public License as
72
published by the Free Software Foundation; either version 2 of the
73
License, or (at your option) any later version.
75
The GNU C Library is distributed in the hope that it will be useful,
76
but WITHOUT ANY WARRANTY; without even the implied warranty of
77
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
78
Library General Public License for more details.
80
You should have received a copy of the GNU Library General Public
81
License along with the GNU C Library; see the file COPYING.LIB. If not,
82
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83
Boston, MA 02111-1307, USA. */
85
/* mp_limb_t mpn_sub_n (mp_ptr res_ptr, mp_srcptr s1_ptr, mp_srcptr s2_ptr,
87
Calculate s1-s2 and put result in res_ptr; return borrow, 0 or 1. */
89
/* Note on optimisation: This code is optimal for the 601. Almost every other
90
possible 2-unrolled inner loop will not be. Also, watch out for the
93
EALIGN(mpihelp_sub_n,3,1)
94
/* Set up for loop below. */
100
/* Set the carry (clear the borrow). */
102
/* Adjust pointers for loop. */
114
/* Align start of loop to an odd word boundary to guarantee that the
115
last two words can be fetched in one access (for 601). This turns
116
out to be important. */
127
/* Return the borrow. */