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