summaryrefslogtreecommitdiff
path: root/mpn/powerpc32/add_n.asm
blob: 3eb45b36b3ec8edebfb5583c12f4c87c7ae47964 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
dnl  PowerPC 750 mpn_add_n -- add mpn limb vectors.
dnl
dnl        cycles/limb
dnl  604e:     2.67
dnl  750:      4.0

dnl  Copyright 2002 Free Software Foundation, Inc.
dnl 
dnl  This file is part of the GNU MP Library.
dnl 
dnl  The GNU MP Library is free software; you can redistribute it and/or
dnl  modify it under the terms of the GNU Lesser General Public License as
dnl  published by the Free Software Foundation; either version 2.1 of the
dnl  License, or (at your option) any later version.
dnl 
dnl  The GNU MP Library is distributed in the hope that it will be useful,
dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
dnl  Lesser General Public License for more details.
dnl 
dnl  You should have received a copy of the GNU Lesser General Public
dnl  License along with the GNU MP Library; see the file COPYING.LIB.  If
dnl  not, write to the Free Software Foundation, Inc., 59 Temple Place -
dnl  Suite 330, Boston, MA 02111-1307, USA.

include(`../config.m4')


C mp_limb_t mpn_add_n (mp_ptr dst, mp_srcptr src1, mp_srcptr src2,
C                      mp_size_t size);
C
C The use of offsets xp-wp and yp-wp is necessary for 4.0 c/l.

ASM_START()
PROLOGUE(mpn_add_n)

	C r3	wp
	C r4	xp
	C r5	yp
	C r6	size

	mtctr	r6		C size
	lwz	r6, 0(r4)	C xp[0]

	lwz	r7, 0(r5)	C yp[0]
	sub	r4, r4, r3	C xp-wp

	sub	r5, r5, r3	C yp-wp
	addi	r4, r4, 4	C xp-wp-4

	addi	r5, r5, 4	C yp-wp-4
	addc	r6, r6, r7

	stw	r6, 0(r3)	C wp[0]
	bdz	L(done)


L(top):
	C r3	wp, incrementing
	C r4	xp-wp+4
	C r5	yp-wp+4
	C r6	scratch
	C r7	scratch

	lwzx	r6, r4,r3	C xp[i]

	lwzx	r7, r5,r3	C yp[i]

	C serialize
	adde	r6, r6, r7

	stwu	r6, 4(r3)	C wp[i]
	bdnz	L(top)


L(done):
	li	r3, 0

	addze	r3, r3		C carry out
	blr

EPILOGUE()