+++ /dev/null
-;/*++\r
-;\r
-;Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-;This program and the accompanying materials \r
-;are licensed and made available under the terms and conditions of the BSD License \r
-;which accompanies this distribution. The full text of the license may be found at \r
-;http://opensource.org/licenses/bsd-license.php \r
-; \r
-;THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-;WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
-;\r
-;Module Name:\r
-;\r
-; GetPowerOfTwo.c\r
-;\r
-;Abstract:\r
-;\r
-; Calculates the largest integer that is both \r
-; a power of two and less than Input\r
-;\r
-;--*/\r
-;---------------------------------------------------------------------------\r
- .686\r
- .model flat,C\r
- .code\r
-\r
-;---------------------------------------------------------------------------\r
-\r
-;UINT64\r
-;GetPowerOfTwo (\r
-; IN UINT64 Input\r
-; )\r
-;/*++\r
-;\r
-;Routine Description:\r
-;\r
-; Calculates the largest integer that is both \r
-; a power of two and less than Input\r
-;\r
-;Arguments:\r
-;\r
-; Input - value to calculate power of two\r
-;\r
-;Returns:\r
-;\r
-; the largest integer that is both a power of \r
-; two and less than Input\r
-;\r
-;--*/\r
-GetPowerOfTwo PROC\r
- xor eax, eax\r
- mov edx, eax\r
- mov ecx, [esp + 8] ; dword ptr Input[4]\r
- jecxz _F\r
- bsr ecx, ecx\r
- bts edx, ecx\r
- jmp _Exit\r
-_F:\r
- mov ecx, [esp + 4] ; dword ptr Input[0]\r
- jecxz _Exit\r
- bsr ecx, ecx\r
- bts eax, ecx\r
-_Exit:\r
-\r
- ret\r
-GetPowerOfTwo ENDP\r
- END\r