]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/Ia32/RShiftU64.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[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 Shifts a 64-bit integer right between 0 and 63 bits. This high bits
11 are filled with zeros. The shifted value is returned.
12
13 This function shifts the 64-bit value Operand to the right by Count bits. The
14 high Count bits are set to zero. The shifted value is returned.
15
16 @param Operand The 64-bit operand to shift right.
17 @param Count The number of bits to shift right.
18
19 @return Operand >> Count
20
21 **/
22 UINT64
23 EFIAPI
24 InternalMathRShiftU64 (
25 IN UINT64 Operand,
26 IN UINTN Count
27 )
28 {
29 _asm {
30 mov cl, byte ptr [Count]
31 xor edx, edx
32 mov eax, dword ptr [Operand + 4]
33 test cl, 32
34 jnz L0
35 mov edx, eax
36 mov eax, dword ptr [Operand + 0]
37 L0:
38 shrd eax, edx, cl
39 shr edx, cl
40 }
41 }