]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/Ia32/RShiftU64.c
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / BaseLib / Ia32 / RShiftU64.c
1 /** @file
2 64-bit logical right shift function for IA-32
3
4 Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9
10
11
12 /**
13 Shifts a 64-bit integer right between 0 and 63 bits. This high bits
14 are filled with zeros. The shifted value is returned.
15
16 This function shifts the 64-bit value Operand to the right by Count bits. The
17 high Count bits are set to zero. The shifted value is returned.
18
19 @param Operand The 64-bit operand to shift right.
20 @param Count The number of bits to shift right.
21
22 @return Operand >> Count
23
24 **/
25 UINT64
26 EFIAPI
27 InternalMathRShiftU64 (
28 IN UINT64 Operand,
29 IN UINTN Count
30 )
31 {
32 _asm {
33 mov cl, byte ptr [Count]
34 xor edx, edx
35 mov eax, dword ptr [Operand + 4]
36 test cl, 32
37 jnz L0
38 mov edx, eax
39 mov eax, dword ptr [Operand + 0]
40 L0:
41 shrd eax, edx, cl
42 shr edx, cl
43 }
44 }
45