]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Log2.asm
Maintainers.txt: Remove EdkCompatibilityPkg information
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / EfiCommonLib / Ia32 / Log2.asm
CommitLineData
478db76b 1;/*++\r
2;\r
4ea9375a
HT
3;Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
4;This program and the accompanying materials \r
478db76b 5;are licensed and made available under the terms and conditions of the BSD License \r
6;which accompanies this distribution. The full text of the license may be found at \r
7;http://opensource.org/licenses/bsd-license.php \r
8; \r
9;THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10;WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11;\r
12;Module Name:\r
13;\r
14; Log2.c\r
15;\r
16;Abstract:\r
17;\r
18; 64-bit integer logarithm function for IA-32\r
19;\r
20;--*/\r
21;\r
22;---------------------------------------------------------------------------\r
23 .686\r
24 .model flat,C\r
25 .code\r
26\r
27;---------------------------------------------------------------------------\r
28\r
29;UINT8\r
30;Log2 (\r
31; IN UINT64 Operand\r
32; )\r
33;/*++\r
34;\r
35;Routine Description:\r
36; \r
37; Calculates and floors logarithms based on 2\r
38;\r
39;Arguments:\r
40;\r
41; Operand - value to calculate logarithm\r
42; \r
43;Returns:\r
44;\r
45; The largest integer that is less than or equal\r
46; to the logarithm of Operand based on 2 \r
47;\r
48;--*/\r
49Log2 PROC\r
50 mov ecx, 64\r
51 \r
52 cmp dword ptr [esp + 4], 0 ; (UINT32 *(&Operand))\r
53 jne _Log2_Wend \r
54 cmp dword ptr [esp + 8], 0 ; (UINT32 *(&Operand)) + 1\r
55 jne _Log2_Wend \r
56 mov cl, 0FFH\r
57 jmp _Log2_Done\r
58 \r
59_Log2_Wend:\r
60 dec ecx\r
61 cmp ecx, 32\r
62 jae _Log2_Higher\r
63 bt [esp + 4], ecx ; (UINT32 *(&Operand))\r
64 jmp _Log2_Bit\r
65 \r
66_Log2_Higher:\r
67 mov eax, ecx\r
68 sub eax, 32\r
69 bt [esp + 8], eax ; (UINT32 *(&Operand)) + 1\r
70 \r
71_Log2_Bit:\r
72 jc _Log2_Done\r
73 jmp _Log2_Wend\r
74 \r
75_Log2_Done:\r
76 mov al, cl\r
77\r
78 ret\r
79\r
80 Log2 ENDP\r
81 END\r