]> git.proxmox.com Git - mirror_edk2.git/blame - CryptoPkg/Library/IntrinsicLib/Ia32/MathRShiftU64.c
CryptoPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / CryptoPkg / Library / IntrinsicLib / Ia32 / MathRShiftU64.c
CommitLineData
97f98500
HT
1/** @file\r
2 64-bit Math Worker Function.\r
3 The 32-bit versions of C compiler generate calls to library routines\r
4 to handle 64-bit math. These functions use non-standard calling conventions.\r
5\r
2ac68e8b 6Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
2009f6b4 7SPDX-License-Identifier: BSD-2-Clause-Patent\r
97f98500
HT
8\r
9**/\r
10\r
11\r
12/*\r
13 * Shifts a 64-bit unsigned value right by a certain number of bits.\r
14 */\r
15__declspec(naked) void __cdecl _aullshr (void)\r
16{\r
17 _asm {\r
18 ;\r
19 ; Checking: Only handle 64bit shifting or more\r
20 ;\r
21 cmp cl, 64\r
22 jae _Exit\r
23\r
24 ;\r
25 ; Handle shifting between 0 and 31 bits\r
26 ;\r
27 cmp cl, 32\r
28 jae More32\r
29 shrd eax, edx, cl\r
30 shr edx, cl\r
31 ret\r
32\r
33 ;\r
34 ; Handle shifting of 32-63 bits\r
35 ;\r
36More32:\r
37 mov eax, edx\r
38 xor edx, edx\r
39 and cl, 31\r
40 shr eax, cl\r
41 ret\r
42\r
43 ;\r
44 ; Invalid number (less then 32bits), return 0\r
45 ;\r
46_Exit:\r
47 xor eax, eax\r
48 xor edx, edx\r
49 ret\r
50 }\r
51}\r