2009-05-12 15:37:47 -04:00
|
|
|
|
|
|
|
; Copyright 2009 Jason Moxham
|
2009-09-02 07:41:43 -04:00
|
|
|
;
|
|
|
|
; Windows Conversion Copyright 2008 Brian Gladman
|
|
|
|
;
|
2009-05-12 15:37:47 -04:00
|
|
|
; This file is part of the MPIR Library.
|
2009-09-02 07:41:43 -04:00
|
|
|
;
|
2009-05-12 15:37:47 -04:00
|
|
|
; 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 07:41:43 -04:00
|
|
|
; return bottom bit of difference
|
|
|
|
; subtraction treated as two compliment
|
|
|
|
;
|
|
|
|
; mp_limb_t mpn_rsh1sub_n(mp_ptr, mp_ptr, mp_ptr, mp_size_t)
|
|
|
|
; rax rdi rsi rdx rcx
|
2010-07-02 07:52:24 -04:00
|
|
|
; rax rcx rdx r8 r9
|
2009-05-12 15:37:47 -04:00
|
|
|
|
2010-08-15 06:08:57 -04:00
|
|
|
%include "yasm_mac.inc"
|
2009-05-12 15:37:47 -04:00
|
|
|
|
|
|
|
%define reg_save_list rbx, rsi, rdi, r12
|
|
|
|
|
|
|
|
CPU Athlon64
|
|
|
|
BITS 64
|
|
|
|
|
|
|
|
FRAME_PROC mpn_rsh1sub_n, 0, reg_save_list
|
2010-07-02 07:52:24 -04:00
|
|
|
mov rax, r9
|
2009-05-12 15:37:47 -04:00
|
|
|
lea rdi, [rcx+rax*8-32]
|
|
|
|
lea rsi, [rdx+rax*8-32]
|
|
|
|
lea rdx, [r8+rax*8-32]
|
|
|
|
mov rcx, rax
|
|
|
|
|
|
|
|
mov r8, 4
|
|
|
|
sub r8, rcx
|
|
|
|
mov r12, [rsi+r8*8]
|
|
|
|
sub r12, [rdx+r8*8]
|
|
|
|
sbb rbx, rbx
|
|
|
|
mov rax, r12
|
|
|
|
and rax, 1
|
|
|
|
cmp r8, 0
|
2009-12-02 11:24:00 -05:00
|
|
|
jge .2
|
2010-07-22 07:33:16 -04:00
|
|
|
.1: mov r11, [rsi+r8*8+32]
|
2009-05-12 15:37:47 -04:00
|
|
|
mov r10, [rsi+r8*8+24]
|
|
|
|
add rbx, 1
|
|
|
|
mov rcx, [rsi+r8*8+8]
|
|
|
|
mov r9, [rsi+r8*8+16]
|
|
|
|
sbb rcx, [rdx+r8*8+8]
|
|
|
|
sbb r9, [rdx+r8*8+16]
|
|
|
|
sbb r10, [rdx+r8*8+24]
|
|
|
|
sbb r11, [rdx+r8*8+32]
|
|
|
|
sbb rbx, rbx
|
|
|
|
bt r11, 0
|
|
|
|
rcr r10, 1
|
|
|
|
rcr r9, 1
|
|
|
|
rcr rcx, 1
|
|
|
|
rcr r12, 1
|
|
|
|
mov [rdi+r8*8], r12
|
|
|
|
mov [rdi+r8*8+8], rcx
|
|
|
|
mov [rdi+r8*8+16], r9
|
|
|
|
mov [rdi+r8*8+24], r10
|
|
|
|
mov r12, r11
|
|
|
|
add r8, 4
|
2009-12-02 11:24:00 -05:00
|
|
|
jnc .1
|
2010-07-22 07:33:16 -04:00
|
|
|
.2: cmp r8, 2
|
2009-12-02 11:24:00 -05:00
|
|
|
ja .6
|
|
|
|
jz .5
|
|
|
|
jp .4
|
2010-07-22 07:33:16 -04:00
|
|
|
.3: mov r10, [rsi+r8*8+24]
|
2009-05-12 15:37:47 -04:00
|
|
|
add rbx, 1
|
|
|
|
mov rcx, [rsi+r8*8+8]
|
|
|
|
mov r9, [rsi+r8*8+16]
|
|
|
|
sbb rcx, [rdx+r8*8+8]
|
|
|
|
sbb r9, [rdx+r8*8+16]
|
|
|
|
sbb r10, [rdx+r8*8+24]
|
|
|
|
rcr r10, 1
|
|
|
|
rcr r9, 1
|
|
|
|
rcr rcx, 1
|
|
|
|
rcr r12, 1
|
|
|
|
mov [rdi+r8*8], r12
|
|
|
|
mov [rdi+r8*8+8], rcx
|
|
|
|
mov [rdi+r8*8+16], r9
|
|
|
|
mov [rdi+r8*8+24], r10
|
2010-07-22 07:33:16 -04:00
|
|
|
EXIT_PROC reg_save_list
|
|
|
|
|
2009-05-12 15:37:47 -04:00
|
|
|
xalign 16
|
2010-07-22 07:33:16 -04:00
|
|
|
.4: add rbx, 1
|
2009-05-12 15:37:47 -04:00
|
|
|
mov rcx, [rsi+r8*8+8]
|
|
|
|
mov r9, [rsi+r8*8+16]
|
|
|
|
sbb rcx, [rdx+r8*8+8]
|
|
|
|
sbb r9, [rdx+r8*8+16]
|
|
|
|
rcr r9, 1
|
|
|
|
rcr rcx, 1
|
|
|
|
rcr r12, 1
|
|
|
|
mov [rdi+r8*8], r12
|
|
|
|
mov [rdi+r8*8+8], rcx
|
|
|
|
mov [rdi+r8*8+16], r9
|
2010-07-22 07:33:16 -04:00
|
|
|
EXIT_PROC reg_save_list
|
|
|
|
|
2009-05-12 15:37:47 -04:00
|
|
|
xalign 16
|
2010-07-22 07:33:16 -04:00
|
|
|
.5: add rbx, 1
|
2009-05-12 15:37:47 -04:00
|
|
|
mov rcx, [rsi+r8*8+8]
|
|
|
|
sbb rcx, [rdx+r8*8+8]
|
|
|
|
rcr rcx, 1
|
|
|
|
rcr r12, 1
|
|
|
|
mov [rdi+r8*8], r12
|
|
|
|
mov [rdi+r8*8+8], rcx
|
2010-07-22 07:33:16 -04:00
|
|
|
EXIT_PROC reg_save_list
|
|
|
|
|
2009-05-12 15:37:47 -04:00
|
|
|
xalign 16
|
2010-07-22 07:33:16 -04:00
|
|
|
.6: add rbx, 1
|
2009-05-12 15:37:47 -04:00
|
|
|
rcr r12, 1
|
|
|
|
mov [rdi+r8*8], r12
|
2010-07-22 07:33:16 -04:00
|
|
|
.7: END_PROC reg_save_list
|
2009-12-02 11:24:00 -05:00
|
|
|
|
2009-05-12 15:37:47 -04:00
|
|
|
end
|