PDA

View Full Version : Usage of OS_IsFeaturePresent Keyword



Michael Clease
30-05-2007, 23:28
I was thinking of using the array i created and loop through the OS_IsFeaturePresent to make the code smaller.



uses "OS"

dim N(14) AS dword
DIM i AS Byte
DIM sMsg as STRING
DIM lType AS STRING

Dim ArrayName() As String
Dim Delimiter As String VALUE "," ' Character used to seperate
Dim nTokens As DWORD
Dim Counter As DWORD

if OS_WinGetVersionTimeline < %OS_Windows_nt then
MSGBOX 0, "SORRY FUNCTION NOT AVAILABLE"
STOP
ELSE
lType = "%PF_FLOATING_POINT_PRECISION_ERRATA,"
lType += "%PF_FLOATING_POINT_EMULATED,%PF_COMPARE_EXCHANGE_DOUBLE,"
lType += "%PF_MMX_INSTRUCTIONS_AVAILABLE,%PF_XMMI_INSTRUCTIONS_AVAILABLE,"
lType += "%PF_RDTSC_INSTRUCTION_AVAILABLE,%PF_3DNOW_INSTRUCTIONS_AVAILABLE,"
lType += "%PF_PAE_ENABLED,%PF_XMMI64_INSTRUCTIONS_AVAILABLE,%PF_NX_ENABLED,"
lType += "%PF_SSE3_INSTRUCTIONS_AVAILABLE,%PF_COMPARE_EXCHANGE128,"
lType += "%PF_COMPARE64_EXCHANGE128,%PF_CHANNELS_ENABLED"

N(1) = OS_IsFeaturePresent(%PF_FLOATING_POINT_PRECISION_ERRATA)
N(2) = OS_IsFeaturePresent(%PF_FLOATING_POINT_EMULATED)
N(3) = OS_IsFeaturePresent(%PF_COMPARE_EXCHANGE_DOUBLE)
N(4) = OS_IsFeaturePresent(%PF_MMX_INSTRUCTIONS_AVAILABLE)
N(5) = OS_IsFeaturePresent(%PF_XMMI_INSTRUCTIONS_AVAILABLE)
N(6) = OS_IsFeaturePresent(%PF_RDTSC_INSTRUCTION_AVAILABLE)
N(7) = OS_IsFeaturePresent(%PF_3DNOW_INSTRUCTIONS_AVAILABLE)
N(8) = OS_IsFeaturePresent(%PF_PAE_ENABLED)
N(9) = OS_IsFeaturePresent(%PF_XMMI64_INSTRUCTIONS_AVAILABLE)
N(10) = OS_IsFeaturePresent(%PF_NX_ENABLED)
N(11) = OS_IsFeaturePresent(%PF_SSE3_INSTRUCTIONS_AVAILABLE)
N(12) = OS_IsFeaturePresent(%PF_COMPARE_EXCHANGE128)
N(13) = OS_IsFeaturePresent(%PF_COMPARE64_EXCHANGE128)
N(14) = OS_IsFeaturePresent(%PF_CHANNELS_ENABLED)

nTokens = SPLIT(lType, Delimiter, ArrayName)
sMsg = "Your Processor supports" & $CRLF & $CRLF

For i = 1 to 14
if n(i) = 1 Then sMsg += ArrayName(i) & $CRLF
ENDIF
Next
ENDIF

MSGBOX 0, sMsg


My CPU

Processor 1 (ID = 0)
Number of cores 2
Number of threads 2 (max 2)
Name Intel Pentium D 930
Codename Presler
Specification Intel(R) Pentium(R) D CPU 3.00GHz
Package Socket 775 LGA (platform ID = 2h)
CPUID F.6.2
Extended CPUID F.6
Core Stepping B1
Technology 65 nm
Core Speed 3010.7 MHz (15.0 x 200.7 MHz)
Rated Bus speed 802.8 MHz
Stock frequency 3000 MHz
Instructions sets MMX, SSE, SSE2, SSE3, EM64T
L1 Data cache 2 x 16 KBytes, 8-way set associative, 64-byte line size
Trace cache 2 x 12 Kuops, 8-way set associative
L2 cache 2 x 2048 KBytes, 8-way set associative, 64-byte line size
FID/VID Control no

ErosOlmi
30-05-2007, 23:59
It is perfect!
Thanks

Michael Clease
31-05-2007, 00:25
Rather than all the program I wrote could is it possible to add or change the keyword to return an array already filled with the values.

ErosOlmi
31-05-2007, 00:34
Rather than all the program I wrote could is it possible to add or change the keyword to return an array already filled with the values.

Yes, maybe an idea. I will post this into feature request forum.

Regarding your example, it seems the string names do not have the same sequence of the values in the array (if I'm not wrong) giving strange results.

Michael Clease
31-05-2007, 01:06
I missed a line. see edited version.

ErosOlmi
31-05-2007, 01:15
mmmh, I think also some other param is not in the same sequence.
Better to use same sequence:

lType += "%PF_FLOATING_POINT_PRECISION_ERRATA,"
lType += "%PF_FLOATING_POINT_EMULATED,"
lType += "%PF_COMPARE_EXCHANGE_DOUBLE,"
lType += "%PF_MMX_INSTRUCTIONS_AVAILABLE,"
lType += "%PF_RDTSC_INSTRUCTION_AVAILABLE,"
lType += "%PF_3DNOW_INSTRUCTIONS_AVAILABLE,"
lType += "%PF_PAE_ENABLED,"
lType += "%PF_XMMI64_INSTRUCTIONS_AVAILABLE,"
lType += "%PF_NX_ENABLED,"
lType += "%PF_SSE3_INSTRUCTIONS_AVAILABLE,"
lType += "%PF_XMMI_INSTRUCTIONS_AVAILABLE,"
lType += "%PF_COMPARE_EXCHANGE128,"
lType += "%PF_COMPARE64_EXCHANGE128,"
lType += "%PF_CHANNELS_ENABLED"

With this problem, you gave me an idea about values assignment ...
... I need some time to think about a possible future implementation of easy assignment of multiple values.

Thanks
Eros

Michael Clease
31-05-2007, 01:34
I should stop cutting and pasting. should be ok now but cpuz report sse3 for my cpu and the program doesnt.

Petr Schreiber
31-05-2007, 08:47
Thanks for this script!,

at least I can see why programs are complaining I have no SSE... as I really don't have it.
But at least 3DNow! is here :)


Bye,
Petr