diff options
Diffstat (limited to 'Core/CPU/x64/x64AsmLib/GetPowerOfTwo64.asm')
-rw-r--r-- | Core/CPU/x64/x64AsmLib/GetPowerOfTwo64.asm | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/Core/CPU/x64/x64AsmLib/GetPowerOfTwo64.asm b/Core/CPU/x64/x64AsmLib/GetPowerOfTwo64.asm new file mode 100644 index 0000000..9cebe72 --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/GetPowerOfTwo64.asm @@ -0,0 +1,84 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/GetPowerOfTwo64.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/GetPowerOfTwo64.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: GetPowerOfTwo64 +; +; Description: +; UINT64 GetPowerOfTwo64(IN UINT64 Input) returns the highest bit set in +; the provided UINT64 Input. Equivalent to 1 << log2(x). +; +; Input: +; IN UINT64 Input +; The 64-bit value to check for its highest bit. +; +; Output: +; UINT64 value of the highest bit; if Input is 0, returns 0. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +GetPowerOfTwo64 proc + bsr rdx, rcx + xor rax, rax + bts rax, rdx + ret +GetPowerOfTwo64 endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* |