EDK2 doxygen online documents - Firmware Encoding Index 1
EDK2 doxygen online documents - Firmware Encoding Index

EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/RShiftU64.c

Go to the documentation of this file.
00001 /*++
00002 
00003 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
00004 This program and the accompanying materials                          
00005 are licensed and made available under the terms and conditions of the BSD License         
00006 which accompanies this distribution.  The full text of the license may be found at        
00007 http://opensource.org/licenses/bsd-license.php                                            
00008                                                                                           
00009 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     
00010 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             
00011 
00012 Module Name:
00013 
00014   RShiftU64.c
00015 
00016 Abstract:
00017 
00018   64-bit right shift function for IA-32
00019 
00020 --*/
00021 
00022 #include "Tiano.h"
00023 
00024 UINT64
00025 RShiftU64 (
00026   IN UINT64   Operand,
00027   IN UINTN    Count
00028   )
00029 /*++
00030 
00031 Routine Description:
00032   This routine allows a 64 bit value to be right shifted by 32 bits and returns the 
00033   shifted value.
00034   Count is valid up 63. (Only Bits 0-5 is valid for Count)
00035 Arguments:
00036   Operand - Value to be shifted
00037   Count   - Number of times to shift right.
00038  
00039 Returns:
00040 
00041   Value shifted right identified by the Count.
00042 
00043 --*/
00044 {
00045   __asm {
00046   
00047     mov    eax, dword ptr Operand[0]
00048     mov    edx, dword ptr Operand[4]
00049   
00050     ;
00051     ; CL is valid from 0 - 31. shld will move EDX:EAX by CL times but EDX is not touched
00052     ; For CL of 32 - 63, it will be shifted 0 - 31 so we will move edx to eax later. 
00053     ;
00054     mov    ecx, Count
00055     and    ecx, 63
00056     shrd   eax, edx, cl
00057     shr    edx, cl
00058 
00059     cmp    ecx, 32
00060     jc     short _RShiftU64_Done
00061 
00062     ;
00063     ; Since Count is 32 - 63, edx will have been shifted  by 0 - 31                                                     
00064     ; If shifted by 32 or more, set upper 32 bits to zero.
00065     ;
00066     mov    eax, edx
00067     xor    edx, edx
00068 
00069 _RShiftU64_Done:
00070   }
00071 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Defines