]> git.proxmox.com Git - mirror_edk2.git/blob - CryptoPkg/Library/IntrinsicLib/Ia32/MathLlshr.asm
CryptoPkg: Add instrinsics to support building ECC on IA32 windows
[mirror_edk2.git] / CryptoPkg / Library / IntrinsicLib / Ia32 / MathLlshr.asm
1 ;***
2 ;llshr.asm - long shift right
3 ;
4 ; Copyright (c) Microsoft Corporation. All rights reserved.
5 ; SPDX-License-Identifier: BSD-2-Clause-Patent
6 ;
7 ;Purpose:
8 ; define signed long shift right routine
9 ; __allshr
10 ;
11 ;Original Implemenation: MSVC 14.12.25827
12 ;
13 ;*******************************************************************************
14 .686
15 .model flat,C
16 .code
17
18
19
20 ;***
21 ;llshr - long shift right
22 ;
23 ;Purpose:
24 ; Does a signed Long Shift Right
25 ; Shifts a long right any number of bits.
26 ;
27 ;Entry:
28 ; EDX:EAX - long value to be shifted
29 ; CL - number of bits to shift by
30 ;
31 ;Exit:
32 ; EDX:EAX - shifted value
33 ;
34 ;Uses:
35 ; CL is destroyed.
36 ;
37 ;Exceptions:
38 ;
39 ;*******************************************************************************
40 _allshr PROC NEAR
41
42 ;
43 ; Handle shifts of 64 bits or more (if shifting 64 bits or more, the result
44 ; depends only on the high order bit of edx).
45 ;
46 cmp cl,64
47 jae short RETSIGN
48
49 ;
50 ; Handle shifts of between 0 and 31 bits
51 ;
52 cmp cl, 32
53 jae short MORE32
54 shrd eax,edx,cl
55 sar edx,cl
56 ret
57
58 ;
59 ; Handle shifts of between 32 and 63 bits
60 ;
61 MORE32:
62 mov eax,edx
63 sar edx,31
64 and cl,31
65 sar eax,cl
66 ret
67
68 ;
69 ; Return double precision 0 or -1, depending on the sign of edx
70 ;
71 RETSIGN:
72 sar edx,31
73 mov eax,edx
74 ret
75
76 _allshr ENDP
77
78 end