]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Log2.c
Update the copyright notice format
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / EfiCommonLib / Ia32 / Log2.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 Log2.c\r
15\r
16Abstract:\r
17\r
18 64-bit integer logarithm function for IA-32\r
19\r
20--*/\r
21\r
22#include "Tiano.h"\r
23\r
24UINT8\r
25Log2 (\r
26 IN UINT64 Operand\r
27 )\r
28/*++\r
29\r
30Routine Description:\r
31 \r
32 Calculates and floors logarithms based on 2\r
33\r
34Arguments:\r
35\r
36 Operand - value to calculate logarithm\r
37 \r
38Returns:\r
39\r
40 The largest integer that is less than or equal\r
41 to the logarithm of Operand based on 2 \r
42\r
43--*/\r
44{\r
45 __asm {\r
46 mov ecx, 64\r
47 \r
48 cmp dword ptr Operand[0], 0\r
49 jne _Log2_Wend \r
50 cmp dword ptr Operand[4], 0\r
51 jne _Log2_Wend \r
52 mov cl, 0FFH\r
53 jmp _Log2_Done\r
54 \r
55_Log2_Wend:\r
56 dec ecx\r
57 cmp ecx, 32\r
58 jae _Log2_Higher\r
59 bt dword ptr Operand[0], ecx\r
60 jmp _Log2_Bit\r
61 \r
62_Log2_Higher:\r
63 mov eax, ecx\r
64 sub eax, 32\r
65 bt dword ptr Operand[4], eax\r
66 \r
67_Log2_Bit:\r
68 jc _Log2_Done\r
69 jmp _Log2_Wend\r
70 \r
71_Log2_Done:\r
72 mov al, cl\r
73 }\r
74}\r