]> git.proxmox.com Git - mirror_edk2.git/blame - CryptoPkg/Library/IntrinsicLib/Ia32/MathRShiftU64.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[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
97f98500
HT
11/*\r
12 * Shifts a 64-bit unsigned value right by a certain number of bits.\r
13 */\r
7c342378
MK
14__declspec(naked) void __cdecl\r
15_aullshr (\r
16 void\r
17 )\r
97f98500
HT
18{\r
19 _asm {\r
20 ;\r
21 ; Checking: Only handle 64bit shifting or more\r
22 ;\r
23 cmp cl, 64\r
24 jae _Exit\r
25\r
26 ;\r
27 ; Handle shifting between 0 and 31 bits\r
28 ;\r
29 cmp cl, 32\r
30 jae More32\r
31 shrd eax, edx, cl\r
32 shr edx, cl\r
33 ret\r
34\r
35 ;\r
36 ; Handle shifting of 32-63 bits\r
37 ;\r
38More32:\r
39 mov eax, edx\r
40 xor edx, edx\r
41 and cl, 31\r
42 shr eax, cl\r
43 ret\r
44\r
45 ;\r
7c342378 46 ; Invalid number (less then 32bits), return 0\r
97f98500 47 ;\r
7c342378 48\r
97f98500
HT
49_Exit:\r
50 xor eax, eax\r
51 xor edx, edx\r
52 ret\r
53 }\r
54}\r