]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseLib/Ia32/RShiftU64.c
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / BaseLib / Ia32 / RShiftU64.c
CommitLineData
e1f414b6 1/** @file\r
2 64-bit logical right shift function for IA-32\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
1efcc4ae 9\r
f734a10a 10\r
e1f414b6 11\r
42eedea9 12/**\r
13 Shifts a 64-bit integer right between 0 and 63 bits. This high bits\r
14 are filled with zeros. The shifted value is returned.\r
15\r
16 This function shifts the 64-bit value Operand to the right by Count bits. The\r
17 high Count bits are set to zero. The shifted value is returned.\r
18\r
19 @param Operand The 64-bit operand to shift right.\r
20 @param Count The number of bits to shift right.\r
21\r
22 @return Operand >> Count\r
23\r
24**/\r
e1f414b6 25UINT64\r
26EFIAPI\r
27InternalMathRShiftU64 (\r
28 IN UINT64 Operand,\r
29 IN UINTN Count\r
30 )\r
31{\r
32 _asm {\r
33 mov cl, byte ptr [Count]\r
34 xor edx, edx\r
35 mov eax, dword ptr [Operand + 4]\r
36 test cl, 32\r
88a75d26
MK
37 jnz L0\r
38 mov edx, eax\r
39 mov eax, dword ptr [Operand + 0]\r
40L0:\r
e1f414b6 41 shrd eax, edx, cl\r
42 shr edx, cl\r
43 }\r
44}\r
45\r