2008-07-03 22:39:50 -04:00
|
|
|
; AMD64 mpn_add_n -- Add two limb vectors of the same length > 0 and store
|
|
|
|
; sum in a third limb vector.
|
|
|
|
;
|
|
|
|
; Copyright 2004 Free Software Foundation, Inc.
|
|
|
|
;
|
2008-07-24 17:14:10 -04:00
|
|
|
; Copyright 2008 William Hart
|
2008-07-03 22:39:50 -04:00
|
|
|
;
|
2008-07-24 17:14:10 -04:00
|
|
|
; This file is part of the MPIR Library.
|
|
|
|
;
|
|
|
|
; The MPIR Library is free software; you can redistribute it and/or modify
|
2008-07-03 22:39:50 -04:00
|
|
|
; it under the terms of the GNU Lesser General Public License as published
|
|
|
|
; by the Free Software Foundation; either version 2.1 of the License, or (at
|
|
|
|
; your option) any later version.
|
|
|
|
;
|
2008-07-24 17:14:10 -04:00
|
|
|
; The MPIR Library is distributed in the hope that it will be useful, but
|
2008-07-03 22:39:50 -04:00
|
|
|
; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
|
|
; License for more details.
|
|
|
|
;
|
|
|
|
; You should have received a copy of the GNU Lesser General Public License
|
2008-07-24 17:14:10 -04:00
|
|
|
; along with the MPIR Library; see the file COPYING.LIB. If not, write
|
2008-07-03 22:39:50 -04:00
|
|
|
; to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
; Boston, MA 02110-1301, USA.
|
|
|
|
;
|
|
|
|
; cycles/limb
|
|
|
|
; Hammer: 3.0
|
|
|
|
;
|
|
|
|
;
|
|
|
|
; INPUT PARAMETERS
|
|
|
|
; rp rdi
|
|
|
|
; up rsi
|
|
|
|
; vp rdx
|
2008-07-23 13:59:51 -04:00
|
|
|
; n rcx
|
2008-07-03 22:39:50 -04:00
|
|
|
|
2009-03-03 16:40:13 -05:00
|
|
|
%include 'yasm_mac.inc'
|
2008-07-03 22:39:50 -04:00
|
|
|
|
2008-07-23 13:59:51 -04:00
|
|
|
BITS 64
|
2008-07-03 22:39:50 -04:00
|
|
|
|
2008-07-23 13:59:51 -04:00
|
|
|
GLOBAL_FUNC mpn_add_n
|
2008-07-03 22:39:50 -04:00
|
|
|
lea rsi, [rsi+rcx*8]
|
|
|
|
lea rdi, [rdi+rcx*8]
|
|
|
|
lea rdx, [rdx+rcx*8]
|
|
|
|
neg rcx
|
|
|
|
xor eax, eax ; clear cy
|
|
|
|
|
|
|
|
align 4 ; minimal alignment for claimed speed
|
2008-07-23 15:31:28 -04:00
|
|
|
loop1: ; do the addition in a loop
|
2008-07-23 13:59:51 -04:00
|
|
|
mov rax, [rsi+rcx*8]
|
2008-07-03 22:39:50 -04:00
|
|
|
mov r10, [rdx+rcx*8]
|
|
|
|
adc rax, r10
|
|
|
|
mov [rdi+rcx*8], rax
|
|
|
|
inc rcx
|
2008-07-23 13:59:51 -04:00
|
|
|
jne loop1
|
2008-07-03 22:39:50 -04:00
|
|
|
|
|
|
|
mov rax, rcx ; zero rax
|
2008-07-23 15:31:28 -04:00
|
|
|
adc rax, rax ; return carry
|
2008-07-03 22:39:50 -04:00
|
|
|
ret
|