xref: /haiku/src/system/libroot/posix/glibc/arch/x86_64/add_n.S (revision 25a7b01d15612846f332751841da3579db313082)
1*a3210bbcSAlex Smith/* Add two limb vectors of the same length > 0 and store sum in a third
2*a3210bbcSAlex Smith   limb vector.
3*a3210bbcSAlex Smith   Copyright (C) 2004 Free Software Foundation, Inc.
4*a3210bbcSAlex Smith   This file is part of the GNU MP Library.
5*a3210bbcSAlex Smith
6*a3210bbcSAlex Smith   The GNU MP Library is free software; you can redistribute it and/or modify
7*a3210bbcSAlex Smith   it under the terms of the GNU Lesser General Public License as published by
8*a3210bbcSAlex Smith   the Free Software Foundation; either version 2.1 of the License, or (at your
9*a3210bbcSAlex Smith   option) any later version.
10*a3210bbcSAlex Smith
11*a3210bbcSAlex Smith   The GNU MP Library is distributed in the hope that it will be useful, but
12*a3210bbcSAlex Smith   WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13*a3210bbcSAlex Smith   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14*a3210bbcSAlex Smith   License for more details.
15*a3210bbcSAlex Smith
16*a3210bbcSAlex Smith   You should have received a copy of the GNU Lesser General Public License
17*a3210bbcSAlex Smith   along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
18*a3210bbcSAlex Smith   the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
19*a3210bbcSAlex Smith   MA 02111-1307, USA. */
20*a3210bbcSAlex Smith
21*a3210bbcSAlex Smith#include "sysdep.h"
22*a3210bbcSAlex Smith#include "asm-syntax.h"
23*a3210bbcSAlex Smith
24*a3210bbcSAlex Smith	.text
25*a3210bbcSAlex SmithENTRY (__mpn_add_n)
26*a3210bbcSAlex Smith	leaq	(%rsi,%rcx,8), %rsi
27*a3210bbcSAlex Smith	leaq	(%rdi,%rcx,8), %rdi
28*a3210bbcSAlex Smith	leaq	(%rdx,%rcx,8), %rdx
29*a3210bbcSAlex Smith	negq	%rcx
30*a3210bbcSAlex Smith	xorl	%eax, %eax			# clear cy
31*a3210bbcSAlex Smith	.p2align 2
32*a3210bbcSAlex SmithL(loop):
33*a3210bbcSAlex Smith	movq	(%rsi,%rcx,8), %rax
34*a3210bbcSAlex Smith	movq	(%rdx,%rcx,8), %r10
35*a3210bbcSAlex Smith	adcq	%r10, %rax
36*a3210bbcSAlex Smith	movq	%rax, (%rdi,%rcx,8)
37*a3210bbcSAlex Smith	incq	%rcx
38*a3210bbcSAlex Smith	jne	L(loop)
39*a3210bbcSAlex Smith	movq	%rcx, %rax			# zero %rax
40*a3210bbcSAlex Smith	adcq	%rax, %rax
41*a3210bbcSAlex Smith	ret
42*a3210bbcSAlex SmithEND (__mpn_add_n)
43