]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | 64-bit arithmetic right shift function for IA-32.\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 | 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 | |
22 | @return Operand arithmetically shifted right by Count.\r | |
23 | \r | |
24 | **/\r | |
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 | |
37 | jnz L0\r | |
38 | mov edx, eax\r | |
39 | mov eax, dword ptr [Operand + 0]\r | |
40 | L0:\r | |
41 | shrd eax, edx, cl\r | |
42 | sar edx, cl\r | |
43 | }\r | |
44 | }\r | |
45 | \r |