2009-03-14 16:55:03 -04:00
|
|
|
|
2009-09-02 13:20:55 -04:00
|
|
|
; Version 1.0.3.
|
|
|
|
;
|
|
|
|
; Copyright 2008 Jason Moxham
|
|
|
|
;
|
2009-05-13 05:54:24 -04:00
|
|
|
; Windows Conversion Copyright 2008 Brian Gladman
|
2009-03-14 16:55:03 -04:00
|
|
|
;
|
|
|
|
; This file is part of the MPIR Library.
|
|
|
|
; The MPIR Library is free software; you can redistribute it and/or modify
|
|
|
|
; 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.
|
|
|
|
; The MPIR Library is distributed in the hope that it will be useful, but
|
|
|
|
; 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
|
|
|
|
; along with the MPIR Library; see the file COPYING.LIB. If not, write
|
|
|
|
; to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
; Boston, MA 02110-1301, USA.
|
|
|
|
;
|
2009-09-02 13:20:55 -04:00
|
|
|
; mp_limb_t mpn_add_n(mp_ptr, mp_srcptr, mp_srcptr, mp_size_t)
|
|
|
|
; mp_limb_t mpn_add_nc(mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, mp_limb_t)
|
|
|
|
; rax rdi rsi rdx rcx r8
|
|
|
|
; rax rcx rdx r8 r9d [rsp+40]
|
2009-03-14 16:55:03 -04:00
|
|
|
|
|
|
|
%include "..\yasm_mac.inc"
|
|
|
|
|
2009-05-13 05:54:24 -04:00
|
|
|
%define TR2 r10
|
|
|
|
%define TR4 r10
|
|
|
|
|
2009-04-03 05:07:52 -04:00
|
|
|
CPU Core2
|
|
|
|
BITS 64
|
|
|
|
|
2009-09-02 13:20:55 -04:00
|
|
|
LEAF_PROC mpn_add_nc
|
2009-08-10 12:47:45 -04:00
|
|
|
mov r10, [rsp+0x28]
|
|
|
|
jmp mpn_add_entry
|
2009-09-02 13:20:55 -04:00
|
|
|
|
2009-08-10 12:47:45 -04:00
|
|
|
LEAF_PROC mpn_add_n
|
2009-09-02 13:20:55 -04:00
|
|
|
xor r10, r10
|
2009-08-10 12:47:45 -04:00
|
|
|
|
|
|
|
mpn_add_entry:
|
2009-05-13 05:54:24 -04:00
|
|
|
movsxd rax, r9d
|
|
|
|
mov r9, rcx
|
|
|
|
mov rcx, rax
|
|
|
|
and rax, 3
|
|
|
|
sub rcx, rax
|
|
|
|
lea r9, [r9+rcx*8]
|
|
|
|
lea rdx, [rdx+rcx*8]
|
|
|
|
lea r8, [r8+rcx*8]
|
|
|
|
neg rcx
|
2009-08-10 12:47:45 -04:00
|
|
|
lea rcx, [r10+rcx*2]
|
|
|
|
sar rcx, 1
|
2009-12-02 11:24:00 -05:00
|
|
|
jz .2
|
2009-09-02 13:20:55 -04:00
|
|
|
|
2009-05-13 05:54:24 -04:00
|
|
|
xalign 16
|
2009-12-02 11:24:00 -05:00
|
|
|
.1:
|
2009-05-13 05:54:24 -04:00
|
|
|
mov r10, [rdx+rcx*8]
|
|
|
|
mov r11, [rdx+rcx*8+16]
|
|
|
|
adc r10, [r8+rcx*8]
|
|
|
|
mov [r9+rcx*8], r10
|
|
|
|
mov TR2, [rdx+rcx*8+8]
|
|
|
|
adc TR2, [r8+rcx*8+8]
|
|
|
|
mov [r9+rcx*8+8], TR2
|
|
|
|
lea rcx, [rcx+4]
|
|
|
|
mov TR4, [rdx+rcx*8-8]
|
|
|
|
adc r11, [r8+rcx*8-16]
|
|
|
|
adc TR4, [r8+rcx*8-8]
|
|
|
|
mov [r9+rcx*8-16], r11
|
|
|
|
mov [r9+rcx*8-8], TR4
|
2009-12-02 11:24:00 -05:00
|
|
|
jrcxz .2
|
|
|
|
jmp .1
|
|
|
|
.2:
|
2009-05-13 05:54:24 -04:00
|
|
|
sbb rcx, rcx
|
2009-12-02 11:24:00 -05:00
|
|
|
.3:
|
2009-05-13 05:54:24 -04:00
|
|
|
cmp rax, 2
|
2009-12-02 11:24:00 -05:00
|
|
|
ja .6
|
|
|
|
jz .7
|
|
|
|
jp .5
|
|
|
|
.4:
|
2009-05-13 05:54:24 -04:00
|
|
|
sub rax, rcx
|
|
|
|
ret
|
2009-12-02 11:24:00 -05:00
|
|
|
|
2009-05-13 05:54:24 -04:00
|
|
|
xalign 16
|
2009-12-02 11:24:00 -05:00
|
|
|
.5:
|
2009-05-13 05:54:24 -04:00
|
|
|
add rcx, rcx
|
|
|
|
mov r10, [rdx]
|
|
|
|
adc r10, [r8]
|
|
|
|
mov [r9], r10
|
|
|
|
sbb rax, rax
|
|
|
|
neg rax
|
|
|
|
ret
|
2009-12-02 11:24:00 -05:00
|
|
|
|
2009-05-13 05:54:24 -04:00
|
|
|
xalign 16
|
2009-12-02 11:24:00 -05:00
|
|
|
.6:
|
2009-05-13 05:54:24 -04:00
|
|
|
add rcx, rcx
|
|
|
|
mov r10, [rdx]
|
|
|
|
mov r11, [rdx+16]
|
|
|
|
adc r10, [r8]
|
|
|
|
mov [r9], r10
|
|
|
|
mov TR2, [rdx+8]
|
|
|
|
adc TR2, [r8+8]
|
|
|
|
mov [r9+8], TR2
|
|
|
|
adc r11, [r8+16]
|
|
|
|
mov [r9+16], r11
|
|
|
|
sbb rax, rax
|
|
|
|
neg rax
|
|
|
|
ret
|
2009-12-02 11:24:00 -05:00
|
|
|
|
2009-05-13 05:54:24 -04:00
|
|
|
xalign 16
|
2009-12-02 11:24:00 -05:00
|
|
|
.7:
|
2009-05-13 05:54:24 -04:00
|
|
|
add rcx, rcx
|
|
|
|
mov r10, [rdx]
|
|
|
|
adc r10, [r8]
|
|
|
|
mov [r9], r10
|
|
|
|
mov TR2, [rdx+8]
|
|
|
|
adc TR2, [r8+8]
|
|
|
|
mov [r9+8], TR2
|
|
|
|
sbb rax, rax
|
|
|
|
neg rax
|
|
|
|
ret
|
2009-12-02 11:24:00 -05:00
|
|
|
|
2009-05-13 05:54:24 -04:00
|
|
|
end
|