2009-02-19 18:22:30 -05:00
|
|
|
|
|
|
|
; AMD64 mpn_lshift1 -- mpn right shift by 1
|
|
|
|
; Version 1.0.4.
|
|
|
|
;
|
|
|
|
; Copyright 2008 Jason Moxham
|
2009-02-22 16:03:08 -05:00
|
|
|
;
|
|
|
|
; Windows Conversion Copyright 2008 Brian Gladman
|
|
|
|
;
|
2009-02-19 18:22:30 -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.
|
2009-02-22 16:03:08 -05:00
|
|
|
;
|
2009-02-19 18:22:30 -05:00
|
|
|
; Calling interface:
|
|
|
|
;
|
|
|
|
; mp_limb_t mpn_lshift1(
|
|
|
|
; mp_ptr dst, rcx
|
|
|
|
; mp_srcptr src, rdx
|
|
|
|
; mp_size_t size, r8
|
|
|
|
; )
|
|
|
|
;
|
|
|
|
; This is an SEH leaf function (no unwind support needed)
|
|
|
|
|
2009-03-07 10:00:35 -05:00
|
|
|
%include "..\yasm_mac.inc"
|
2009-02-19 18:22:30 -05:00
|
|
|
|
|
|
|
%define reg_save_list r12, r13
|
|
|
|
|
2009-03-24 10:40:39 -04:00
|
|
|
CPU Athlon64
|
2009-03-07 10:00:35 -05:00
|
|
|
BITS 64
|
2009-03-13 16:32:09 -04:00
|
|
|
|
2009-03-07 10:00:35 -05:00
|
|
|
FRAME_PROC mpn_lshift1, 0, reg_save_list
|
2009-03-09 17:27:31 -04:00
|
|
|
movsxd r8, r8d
|
2009-03-13 16:32:09 -04:00
|
|
|
xor rax, rax
|
|
|
|
mov r9, r8
|
|
|
|
and r9, 7
|
|
|
|
inc r9
|
|
|
|
shr r8, 3
|
2009-02-19 18:22:30 -05:00
|
|
|
; and clear carry flag
|
2009-03-13 16:32:09 -04:00
|
|
|
cmp r8, 0
|
|
|
|
jz .2
|
|
|
|
|
2009-03-24 10:40:39 -04:00
|
|
|
xalign 16
|
2009-03-13 16:32:09 -04:00
|
|
|
.1: mov r10, [rdx]
|
|
|
|
mov r11, [rdx+8]
|
|
|
|
mov r12, [rdx+16]
|
|
|
|
mov r13, [rdx+24]
|
|
|
|
adc r10, r10
|
|
|
|
adc r11, r11
|
|
|
|
adc r12, r12
|
|
|
|
adc r13, r13
|
|
|
|
mov [rcx], r10
|
|
|
|
mov [rcx+8], r11
|
|
|
|
mov [rcx+16], r12
|
|
|
|
mov [rcx+24], r13
|
|
|
|
mov r10, [rdx+32]
|
|
|
|
mov r11, [rdx+40]
|
|
|
|
mov r12, [rdx+48]
|
|
|
|
mov r13, [rdx+56]
|
|
|
|
adc r10, r10
|
|
|
|
adc r11, r11
|
|
|
|
adc r12, r12
|
|
|
|
adc r13, r13
|
|
|
|
mov [rcx+32], r10
|
|
|
|
mov [rcx+40], r11
|
|
|
|
mov [rcx+48], r12
|
|
|
|
mov [rcx+56], r13
|
|
|
|
lea rcx, [rcx+64]
|
|
|
|
dec r8
|
|
|
|
lea rdx, [rdx+64]
|
|
|
|
jnz .1
|
2009-02-19 18:22:30 -05:00
|
|
|
.2:
|
2009-03-13 16:32:09 -04:00
|
|
|
dec r9
|
|
|
|
jz .3
|
2009-02-19 18:22:30 -05:00
|
|
|
; Could still have cache-bank conflicts in this tail part
|
2009-03-13 16:32:09 -04:00
|
|
|
mov r10, [rdx]
|
|
|
|
adc r10, r10
|
|
|
|
mov [rcx], r10
|
|
|
|
dec r9
|
|
|
|
jz .3
|
|
|
|
mov r10, [rdx+8]
|
|
|
|
adc r10, r10
|
|
|
|
mov [rcx+8], r10
|
|
|
|
dec r9
|
|
|
|
jz .3
|
|
|
|
mov r10, [rdx+16]
|
|
|
|
adc r10, r10
|
|
|
|
mov [rcx+16], r10
|
|
|
|
dec r9
|
|
|
|
jz .3
|
|
|
|
mov r10, [rdx+24]
|
|
|
|
adc r10, r10
|
|
|
|
mov [rcx+24], r10
|
|
|
|
dec r9
|
|
|
|
jz .3
|
|
|
|
mov r10, [rdx+32]
|
|
|
|
adc r10, r10
|
|
|
|
mov [rcx+32], r10
|
|
|
|
dec r9
|
|
|
|
jz .3
|
|
|
|
mov r10, [rdx+40]
|
|
|
|
adc r10, r10
|
|
|
|
mov [rcx+40], r10
|
|
|
|
dec r9
|
|
|
|
jz .3
|
|
|
|
mov r10, [rdx+48]
|
|
|
|
adc r10, r10
|
|
|
|
mov [rcx+48], r10
|
2009-02-19 18:22:30 -05:00
|
|
|
.3:
|
2009-03-13 16:32:09 -04:00
|
|
|
adc rax, rax
|
2009-03-07 10:00:35 -05:00
|
|
|
END_PROC reg_save_list
|
2009-02-19 18:22:30 -05:00
|
|
|
|
|
|
|
end
|