Debian Codegraph @

msvc/gmp/mpn/amd64i/lshift.asm

raw
1
2 ; AMD64 mpn_lshift -- mpn left shift
3 ;
4 ; Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
5 ;
6 ; This file is part of the GNU MP Library.
7 ;
8 ; The GNU MP Library is free software; you can redistribute it and/or
9 ; modify it under the terms of the GNU Lesser General Public License as
10 ; published by the Free Software Foundation; either version 2.1 of the
11 ; License, or (at your option) any later version.
12 ;
13 ; The GNU MP Library is distributed in the hope that it will be useful,
14 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 ; Lesser General Public License for more details.
17 ;
18 ; You should have received a copy of the GNU Lesser General Public
19 ; License along with the GNU MP Library; see the file COPYING.LIB. If
20 ; not, write to the Free Software Foundation, Inc., 59 Temple Place -
21 ; Suite 330, Boston, MA 02111-1307, USA.
22 ;
23 ; Adapted by Brian Gladman AMD64 using the Microsoft VC++ v8 64-bit
24 ; compiler and the YASM assembler.
25 ;
26 ; Calling interface:
27 ;
28 ; mp_limb_t mpn_lshift(
29 ; mp_ptr dst, rcx
30 ; mp_srcptr src, rdx
31 ; mp_size_t size, r8
32 ; unsigned shift r9
33 ; )
34
35 %define s_len r8
36 %define r_tmp r9
37 %define d_ptr r10
38 %define s_ptr r11
39
40 bits 64
41 text
42
43 global __gmpn_lshift
44
45 %ifdef DLL
46 export __gmpn_lshift
47 %endif
48
49 __gmpn_lshift:
50 movsxd s_len,r8d
51 or s_len,s_len
52 jz .0
53 mov d_ptr,rcx
54 mov s_ptr,rdx
55 mov rcx,r9
56 cmp s_len,byte 2
57 jge .1
58 or s_len,s_len
59 mov rax,[s_ptr]
60 mov r_tmp,rax
61 shl r_tmp,cl
62 neg cl
63 mov [d_ptr],r_tmp
64 shr rax,cl
65 .0: ret
66 .1: dec s_len
67 mov rdx,[s_ptr+s_len*8]
68 push rdx
69 .2: mov rax,[s_ptr+s_len*8-8]
70 mov r_tmp,rax
71 shl rdx,cl
72 neg cl
73 shr r_tmp,cl
74 neg cl
75 or r_tmp,rdx
76 mov rdx,rax
77 mov [d_ptr+s_len*8],r_tmp
78 dec s_len
79 jnz .2
80 shl rax,cl
81 mov [d_ptr],rax
82 neg cl
83 pop rax
84 shr rax,cl
85 ret