]>
Commit | Line | Data |
---|---|---|
e1f414b6 | 1 | /** @file\r |
2 | 64-bit arithmetic 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. The high bits\r | |
14 | are filled with original integer's bit 63. 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 bit 63 of Operand. 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 | |
35a17154 | 22 | @return Operand arithmetically shifted right by Count.\r |
42eedea9 | 23 | \r |
24 | **/\r | |
e1f414b6 | 25 | UINT64\r |
26 | EFIAPI\r | |
27 | InternalMathARShiftU64 (\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 | mov eax, dword ptr [Operand + 4]\r | |
35 | cdq\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 | |
40 | L0:\r | |
e1f414b6 | 41 | shrd eax, edx, cl\r |
42 | sar edx, cl\r | |
43 | }\r | |
44 | }\r | |
45 | \r |