]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/GetPowerOfTwo.c
Maintainers.txt: Remove EdkCompatibilityPkg information
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / EfiCommonLib / Ia32 / GetPowerOfTwo.c
CommitLineData
3eb9473e 1/*++\r
2\r
4ea9375a
HT
3Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
4This program and the accompanying materials \r
3eb9473e 5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 GetPowerOfTwo.c\r
15\r
16Abstract:\r
17\r
18 Calculates the largest integer that is both \r
19 a power of two and less than Input\r
20\r
21--*/\r
22\r
23#include "Tiano.h"\r
24\r
25UINT64\r
26GetPowerOfTwo (\r
27 IN UINT64 Input\r
28 )\r
29/*++\r
30\r
31Routine Description:\r
32\r
33 Calculates the largest integer that is both \r
34 a power of two and less than Input\r
35\r
36Arguments:\r
37\r
38 Input - value to calculate power of two\r
39\r
40Returns:\r
41\r
42 the largest integer that is both a power of \r
43 two and less than Input\r
44\r
45--*/\r
46{\r
47 __asm {\r
48 xor eax, eax\r
49 mov edx, eax\r
50 mov ecx, dword ptr Input[4]\r
51 jecxz _F\r
52 bsr ecx, ecx\r
53 bts edx, ecx\r
54 jmp _Exit\r
55_F:\r
56 mov ecx, dword ptr Input[0]\r
57 jecxz _Exit\r
58 bsr ecx, ecx\r
59 bts eax, ecx\r
60_Exit:\r
61 }\r
62}\r