]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/Ia32/RRotU64.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdePkg / Library / BaseLib / Ia32 / RRotU64.c
1 /** @file
2 64-bit right rotation for Ia32
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 Rotates a 64-bit integer right between 0 and 63 bits, filling
11 the high bits with the high low bits that were rotated.
12
13 This function rotates the 64-bit value Operand to the right by Count bits.
14 The high Count bits are fill with the low Count bits of Operand. The rotated
15 value is returned.
16
17 @param Operand The 64-bit operand to rotate right.
18 @param Count The number of bits to rotate right.
19
20 @return Operand >>> Count
21
22 **/
23 UINT64
24 EFIAPI
25 InternalMathRRotU64 (
26 IN UINT64 Operand,
27 IN UINTN Count
28 )
29 {
30 _asm {
31 mov cl, byte ptr [Count]
32 mov eax, dword ptr [Operand + 0]
33 mov edx, dword ptr [Operand + 4]
34 shrd ebx, eax, cl
35 shrd eax, edx, cl
36 rol ebx, cl
37 shrd edx, ebx, cl
38 test cl, 32 // Count >= 32?
39 jz L0
40 mov ecx, eax
41 mov eax, edx
42 mov edx, ecx
43 L0:
44 }
45 }