]>
Commit | Line | Data |
---|---|---|
478db76b | 1 | ;/*++\r |
2 | ;\r | |
4ea9375a HT |
3 | ;Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r |
4 | ;This program and the accompanying materials \r | |
478db76b | 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 | ; LShiftU64.c\r | |
15 | ;\r | |
16 | ;Abstract:\r | |
17 | ;\r | |
18 | ; 64-bit left shift function for IA-32\r | |
19 | ;\r | |
20 | ;--*/\r | |
21 | ;\r | |
22 | ;---------------------------------------------------------------------------\r | |
23 | .686\r | |
24 | .model flat,C\r | |
25 | .code\r | |
26 | \r | |
27 | ;---------------------------------------------------------------------------\r | |
28 | ;\r | |
29 | ;UINT64\r | |
30 | ;LShiftU64 (\r | |
31 | ; IN UINT64 Operand,\r | |
32 | ; IN UINTN Count\r | |
33 | ; )\r | |
34 | ;/*++\r | |
35 | ;\r | |
36 | ;Routine Description:\r | |
37 | ; \r | |
38 | ; This routine allows a 64 bit value to be left shifted by 32 bits and \r | |
39 | ; returns the shifted value.\r | |
40 | ; Count is valid up 63. (Only Bits 0-5 is valid for Count)\r | |
41 | ;\r | |
42 | ;Arguments:\r | |
43 | ;\r | |
44 | ; Operand - Value to be shifted\r | |
45 | ; Count - Number of times to shift left.\r | |
46 | ; \r | |
47 | ;Returns:\r | |
48 | ;\r | |
49 | ; Value shifted left identified by the Count.\r | |
50 | ;\r | |
51 | ;--*/\r | |
52 | LShiftU64 PROC\r | |
53 | \r | |
54 | mov eax, [esp + 4]; dword ptr Operand[0]\r | |
55 | mov edx, [esp + 8]; dword ptr Operand[4]\r | |
56 | \r | |
57 | ;\r | |
58 | ; CL is valid from 0 - 31. shld will move EDX:EAX by CL times but EAX is not touched\r | |
59 | ; For CL of 32 - 63, it will be shifted 0 - 31 so we will move eax to edx later. \r | |
60 | ;\r | |
61 | mov ecx, [esp + 0Ch]; Count\r | |
62 | and ecx, 63\r | |
63 | shld edx, eax, cl\r | |
64 | shl eax, cl\r | |
65 | \r | |
66 | ;\r | |
67 | ; Since Count is 32 - 63, eax will have been shifted by 0 - 31 \r | |
68 | ; If shifted by 32 or more, set lower 32 bits to zero.\r | |
69 | ;\r | |
70 | cmp ecx, 32\r | |
71 | jc short _LShiftU64_Done\r | |
72 | \r | |
73 | mov edx, eax\r | |
74 | xor eax, eax\r | |
75 | \r | |
76 | _LShiftU64_Done:\r | |
77 | \r | |
78 | ret\r | |
79 | LShiftU64 ENDP\r | |
80 | END\r |