]>
Commit | Line | Data |
---|---|---|
478db76b | 1 | ;/*++\r |
2 | ;\r | |
3 | ;Copyright (c) 2006, Intel Corporation \r | |
4 | ;All rights reserved. This program and the accompanying materials \r | |
5 | ;are licensed and made available under the terms and conditions of the BSD License \r | |
6 | ;which accompanies this distribution. The full text of the license may be found at \r | |
7 | ;http://opensource.org/licenses/bsd-license.php \r | |
8 | ; \r | |
9 | ;THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | ;WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | ;\r | |
12 | ;Module Name:\r | |
13 | ;\r | |
14 | ; RShiftU64.c\r | |
15 | ;\r | |
16 | ;Abstract:\r | |
17 | ;\r | |
18 | ; 64-bit right shift function for IA-32\r | |
19 | ;\r | |
20 | ;--*/\r | |
21 | ;\r | |
22 | ;#include "Tiano.h"\r | |
23 | ;\r | |
24 | ;---------------------------------------------------------------------------\r | |
25 | .686\r | |
26 | .model flat,C\r | |
27 | .code\r | |
28 | \r | |
29 | ;---------------------------------------------------------------------------\r | |
30 | ;UINT64\r | |
31 | ;RShiftU64 (\r | |
32 | ; IN UINT64 Operand,\r | |
33 | ; IN UINTN Count\r | |
34 | ; )\r | |
35 | ;/*++\r | |
36 | ;\r | |
37 | ;Routine Description:\r | |
38 | ; This routine allows a 64 bit value to be right shifted by 32 bits and returns the \r | |
39 | ; shifted value.\r | |
40 | ; Count is valid up 63. (Only Bits 0-5 is valid for Count)\r | |
41 | ;Arguments:\r | |
42 | ; Operand - Value to be shifted\r | |
43 | ; Count - Number of times to shift right.\r | |
44 | ; \r | |
45 | ;Returns:\r | |
46 | ;\r | |
47 | ; Value shifted right identified by the Count.\r | |
48 | ;\r | |
49 | ;--*/\r | |
50 | RShiftU64 PROC\r | |
51 | \r | |
52 | mov eax, [esp + 4]; dword ptr Operand[0]\r | |
53 | mov edx, [esp + 8]; dword ptr Operand[4]\r | |
54 | \r | |
55 | ;\r | |
56 | ; CL is valid from 0 - 31. shld will move EDX:EAX by CL times but EDX is not touched\r | |
57 | ; For CL of 32 - 63, it will be shifted 0 - 31 so we will move edx to eax later. \r | |
58 | ;\r | |
59 | mov ecx, [esp + 0Ch] ; Count\r | |
60 | and ecx, 63\r | |
61 | shrd eax, edx, cl\r | |
62 | shr edx, cl\r | |
63 | \r | |
64 | cmp ecx, 32\r | |
65 | jc short _RShiftU64_Done\r | |
66 | \r | |
67 | ;\r | |
68 | ; Since Count is 32 - 63, edx will have been shifted by 0 - 31 \r | |
69 | ; If shifted by 32 or more, set upper 32 bits to zero.\r | |
70 | ;\r | |
71 | mov eax, edx\r | |
72 | xor edx, edx\r | |
73 | \r | |
74 | _RShiftU64_Done:\r | |
75 | \r | |
76 | ret\r | |
77 | RShiftU64 ENDP \r | |
78 | END\r |