]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdePkg/Library/BaseLib/Ia32/LRotU64.c
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / BaseLib / Ia32 / LRotU64.c
... / ...
CommitLineData
1/** @file\r
2 64-bit left rotation for Ia32\r
3\r
4 Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
6\r
7**/\r
8\r
9\r
10\r
11\r
12/**\r
13 Rotates a 64-bit integer left between 0 and 63 bits, filling\r
14 the low bits with the high bits that were rotated.\r
15\r
16 This function rotates the 64-bit value Operand to the left by Count bits. The\r
17 low Count bits are fill with the high Count bits of Operand. The rotated\r
18 value is returned.\r
19\r
20 @param Operand The 64-bit operand to rotate left.\r
21 @param Count The number of bits to rotate left.\r
22\r
23 @return Operand <<< Count\r
24\r
25**/\r
26UINT64\r
27EFIAPI\r
28InternalMathLRotU64 (\r
29 IN UINT64 Operand,\r
30 IN UINTN Count\r
31 )\r
32{\r
33 _asm {\r
34 mov cl, byte ptr [Count]\r
35 mov edx, dword ptr [Operand + 4]\r
36 mov eax, dword ptr [Operand + 0]\r
37 shld ebx, edx, cl\r
38 shld edx, eax, cl\r
39 ror ebx, cl\r
40 shld eax, ebx, cl\r
41 test cl, 32 ; Count >= 32?\r
42 jz L0\r
43 mov ecx, eax\r
44 mov eax, edx\r
45 mov edx, ecx\r
46L0:\r
47 }\r
48}\r
49\r