Author: aandrejevic
Date: Sat Oct 11 15:42:00 2014
New Revision: 64674
URL:
http://svn.reactos.org/svn/reactos?rev=64674&view=rev
Log:
[FAST486]
Use intrinsics to count the leading zeros when possible.
Add FPU data to Fast486DumpState.
Modified:
trunk/reactos/lib/fast486/common.inl
trunk/reactos/lib/fast486/fast486.c
Modified: trunk/reactos/lib/fast486/common.inl
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/common.inl?rev…
==============================================================================
--- trunk/reactos/lib/fast486/common.inl [iso-8859-1] (original)
+++ trunk/reactos/lib/fast486/common.inl [iso-8859-1] Sat Oct 11 15:42:00 2014
@@ -24,6 +24,25 @@
/* PUBLIC FUNCTIONS ***********************************************************/
+#if defined (__GNUC__)
+ #define CountLeadingZeros64(x) __builtin_clzll(x);
+#elif (_MSC_VER >= 1500) && defined(_WIN64)
+ #define CountLeadingZeros64(x) __lzcnt64(x)
+#elif (_MSC_VER >= 1500)
+ #define CountLeadingZeros64(x) ((x) >= 0xFFFFFFFFULL) \
+ ? __lzcnt((x) >> 32) : (__lzcnt(x) + 32)
+#else
+ static
+ FORCEINLINE
+ ULONG CountLeadingZeros64(ULONGLONG Value)
+ {
+ ULONG LeadingZeros = 0;
+
+ while (!(Value & (1 << (63 - LeadingZeros)))) LeadingZeros++;
+ return LeadingZeros;
+ }
+#endif
+
FORCEINLINE
INT
Fast486GetCurrentPrivLevel(PFAST486_STATE State)
@@ -1290,7 +1309,7 @@
VOID
Fast486FpuNormalize(PFAST486_STATE State, PFAST486_FPU_DATA_REG Data)
{
- UINT LeadingZeros = 0;
+ UINT LeadingZeros;
if (FPU_IS_NORMALIZED(Data)) return;
if (FPU_IS_ZERO(Data))
@@ -1299,8 +1318,7 @@
return;
}
- /* Count the leading zeros */
- while (!(Data->Mantissa & (1 << (63 - LeadingZeros)))) LeadingZeros++;
+ LeadingZeros = CountLeadingZeros64(Data->Mantissa);
if (LeadingZeros < Data->Exponent)
{
Modified: trunk/reactos/lib/fast486/fast486.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/fast486.c?rev=…
==============================================================================
--- trunk/reactos/lib/fast486/fast486.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fast486/fast486.c [iso-8859-1] Sat Oct 11 15:42:00 2014
@@ -29,6 +29,7 @@
#include <fast486.h>
#include "common.h"
#include "opcodes.h"
+#include "fpu.h"
/* DEFINES ********************************************************************/
@@ -369,6 +370,35 @@
State->DebugRegisters[FAST486_REG_DR3],
State->DebugRegisters[FAST486_REG_DR4],
State->DebugRegisters[FAST486_REG_DR5]);
+
+#ifndef FAST486_NO_FPU
+ DbgPrint("\nFPU Registers:\n"
+ "ST0 = %04X%016llX\tST1 = %04X%016llX\n"
+ "ST2 = %04X%016llX\tST3 = %04X%016llX\n"
+ "ST4 = %04X%016llX\tST5 = %04X%016llX\n"
+ "ST6 = %04X%016llX\tST7 = %04X%016llX\n"
+ "Status: %04X\tControl: %04X\tTag: %04X\n",
+ FPU_ST(0).Exponent | ((USHORT)FPU_ST(0).Sign << 15),
+ FPU_ST(0).Mantissa,
+ FPU_ST(1).Exponent | ((USHORT)FPU_ST(1).Sign << 15),
+ FPU_ST(1).Mantissa,
+ FPU_ST(2).Exponent | ((USHORT)FPU_ST(2).Sign << 15),
+ FPU_ST(2).Mantissa,
+ FPU_ST(3).Exponent | ((USHORT)FPU_ST(3).Sign << 15),
+ FPU_ST(3).Mantissa,
+ FPU_ST(4).Exponent | ((USHORT)FPU_ST(4).Sign << 15),
+ FPU_ST(4).Mantissa,
+ FPU_ST(5).Exponent | ((USHORT)FPU_ST(5).Sign << 15),
+ FPU_ST(5).Mantissa,
+ FPU_ST(6).Exponent | ((USHORT)FPU_ST(6).Sign << 15),
+ FPU_ST(6).Mantissa,
+ FPU_ST(7).Exponent | ((USHORT)FPU_ST(7).Sign << 15),
+ FPU_ST(7).Mantissa,
+ State->FpuStatus,
+ State->FpuControl,
+ State->FpuTag);
+#endif
+
DbgPrint("\n<-- Fast486DumpState\n\n");
}