]> git.proxmox.com Git - mirror_edk2.git/blame - CryptoPkg/Library/IntrinsicLib/Ia32/MathRShiftU64.c
CryptoPkg:SmmCryptLib: Add real Pkcs5Pbkdf2.c.
[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
97f98500
HT
7This program and the accompanying materials\r
8are licensed and made available under the terms and conditions of the BSD License\r
9which accompanies this distribution. The full text of the license may be found at\r
10http://opensource.org/licenses/bsd-license.php\r
11\r
12THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15**/\r
16\r
17\r
18/*\r
19 * Shifts a 64-bit unsigned value right by a certain number of bits.\r
20 */\r
21__declspec(naked) void __cdecl _aullshr (void)\r
22{\r
23 _asm {\r
24 ;\r
25 ; Checking: Only handle 64bit shifting or more\r
26 ;\r
27 cmp cl, 64\r
28 jae _Exit\r
29\r
30 ;\r
31 ; Handle shifting between 0 and 31 bits\r
32 ;\r
33 cmp cl, 32\r
34 jae More32\r
35 shrd eax, edx, cl\r
36 shr edx, cl\r
37 ret\r
38\r
39 ;\r
40 ; Handle shifting of 32-63 bits\r
41 ;\r
42More32:\r
43 mov eax, edx\r
44 xor edx, edx\r
45 and cl, 31\r
46 shr eax, cl\r
47 ret\r
48\r
49 ;\r
50 ; Invalid number (less then 32bits), return 0\r
51 ;\r
52_Exit:\r
53 xor eax, eax\r
54 xor edx, edx\r
55 ret\r
56 }\r
57}\r