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