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