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