+++ /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
-; Log2.c\r
-;\r
-;Abstract:\r
-;\r
-; 64-bit integer logarithm function for IA-32\r
-;\r
-;--*/\r
-;\r
-;---------------------------------------------------------------------------\r
- .686\r
- .model flat,C\r
- .code\r
-\r
-;---------------------------------------------------------------------------\r
-\r
-;UINT8\r
-;Log2 (\r
-; IN UINT64 Operand\r
-; )\r
-;/*++\r
-;\r
-;Routine Description:\r
-; \r
-; Calculates and floors logarithms based on 2\r
-;\r
-;Arguments:\r
-;\r
-; Operand - value to calculate logarithm\r
-; \r
-;Returns:\r
-;\r
-; The largest integer that is less than or equal\r
-; to the logarithm of Operand based on 2 \r
-;\r
-;--*/\r
-Log2 PROC\r
- mov ecx, 64\r
- \r
- cmp dword ptr [esp + 4], 0 ; (UINT32 *(&Operand))\r
- jne _Log2_Wend \r
- cmp dword ptr [esp + 8], 0 ; (UINT32 *(&Operand)) + 1\r
- jne _Log2_Wend \r
- mov cl, 0FFH\r
- jmp _Log2_Done\r
- \r
-_Log2_Wend:\r
- dec ecx\r
- cmp ecx, 32\r
- jae _Log2_Higher\r
- bt [esp + 4], ecx ; (UINT32 *(&Operand))\r
- jmp _Log2_Bit\r
- \r
-_Log2_Higher:\r
- mov eax, ecx\r
- sub eax, 32\r
- bt [esp + 8], eax ; (UINT32 *(&Operand)) + 1\r
- \r
-_Log2_Bit:\r
- jc _Log2_Done\r
- jmp _Log2_Wend\r
- \r
-_Log2_Done:\r
- mov al, cl\r
-\r
- ret\r
-\r
- Log2 ENDP\r
- END\r