mpir/mpn/x86_64w/nehalem/mul_2.asm

146 lines
3.4 KiB
NASM
Raw Normal View History

2009-12-03 12:32:55 -05:00
; X86_64 mpn_mul_2
;
; Copyright 2010 Jason Moxham
2009-12-03 12:32:55 -05:00
;
; Windows Conversion Copyright 2010 Brian Gladman
2009-12-03 12:32:55 -05: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.
;
; mp_limb_t mpn_mul_2(mp_ptr, mp_ptr, mp_size_t, mp_limb_t)
; rax rdi rsi rdx rcx
; rax rcx rdx r8 r9
2009-12-03 12:32:55 -05:00
%include "yasm_mac.inc"
2009-12-03 12:32:55 -05:00
%define reg_save_list rsi, rdi, rbx
BITS 64
FRAME_PROC mpn_mul_2, 0, reg_save_list
mov rax, r8
2009-12-03 12:32:55 -05:00
lea rdi, [rcx+rax*8-24]
lea rsi, [rdx+rax*8-24]
mov r8, [r9+8]
mov rcx, [r9]
2009-12-03 12:32:55 -05:00
mov rbx, 3
2009-12-03 12:32:55 -05:00
sub rbx, rax
mov r11, 0
mov r9, 0
mov rax, [rsi+rbx*8]
2009-12-03 12:32:55 -05:00
mov r10, 0
mul rcx
add r11, rax
2009-12-03 12:32:55 -05:00
mov rax, [rsi+rbx*8]
mov [rdi+rbx*8], r11
adc r9, rdx
2009-12-03 12:32:55 -05:00
cmp rbx, 0
jge .1
2009-12-03 12:32:55 -05:00
xalign 16
.0: mul r8
2009-12-03 12:32:55 -05:00
add r9, rax
adc r10, rdx
mov rax, [rsi+rbx*8+8]
mov r11, 0
mul rcx
2009-12-03 12:32:55 -05:00
add r9, rax
adc r10, rdx
adc r11, 0
mov rax, [rsi+rbx*8+8]
mul r8
add r10, rax
mov rax, [rsi+rbx*8+16]
adc r11, rdx
2009-12-03 12:32:55 -05:00
mul rcx
add r10, rax
mov [rdi+rbx*8+8], r9
adc r11, rdx
mov r9, 0
mov rax, [rsi+rbx*8+16]
adc r9, 0
mul r8
2009-12-03 12:32:55 -05:00
add r11, rax
mov [rdi+rbx*8+16], r10
2009-12-03 12:32:55 -05:00
mov rax, [rsi+rbx*8+24]
mov r10, 0
2009-12-03 12:32:55 -05:00
adc r9, rdx
mul rcx
2009-12-03 12:32:55 -05:00
add r11, rax
mov rax, [rsi+rbx*8+24]
mov [rdi+rbx*8+24], r11
2009-12-03 12:32:55 -05:00
adc r9, rdx
adc r10, 0
add rbx, 3
jnc .0
.1: cmp rbx, 1
ja .4
je .3
.2: mul r8
2009-12-03 12:32:55 -05:00
add r9, rax
adc r10, rdx
mov rax, [rsi+rbx*8+8]
mov r11, 0
mul rcx
2009-12-03 12:32:55 -05:00
add r9, rax
adc r10, rdx
adc r11, 0
mov rax, [rsi+rbx*8+8]
mul r8
add r10, rax
mov rax, [rsi+rbx*8+16]
adc r11, rdx
2009-12-03 12:32:55 -05:00
mul rcx
add r10, rax
mov [rdi+rbx*8+8], r9
adc r11, rdx
mov r9, 0
mov rax, [rsi+rbx*8+16]
adc r9, 0
mul r8
2009-12-03 12:32:55 -05:00
add r11, rax
mov [rdi+rbx*8+16], r10
2009-12-03 12:32:55 -05:00
adc r9, rdx
mov [rdi+rbx*8+24], r11
mov rax, r9
EXIT_PROC reg_save_list
2009-12-03 12:32:55 -05:00
.3: mul r8
2009-12-03 12:32:55 -05:00
add r9, rax
adc r10, rdx
2009-12-03 12:32:55 -05:00
mov rax, [rsi+rbx*8+8]
mov r11, 0
mul rcx
add r9, rax
2009-12-03 12:32:55 -05:00
adc r10, rdx
adc r11, 0
mov rax, [rsi+rbx*8+8]
mul r8
2009-12-03 12:32:55 -05:00
add r10, rax
adc r11, rdx
mov [rdi+rbx*8+8], r9
2009-12-03 12:32:55 -05:00
mov [rdi+rbx*8+16], r10
mov rax, r11
EXIT_PROC reg_save_list
.4: mul r8
add r9, rax
adc r10, rdx
mov [rdi+rbx*8+8], r9
2009-12-03 12:32:55 -05:00
mov rax, r10
END_PROC reg_save_list
2009-12-03 12:32:55 -05:00
end