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