Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

CPUID functions

Aug
1,949
71
Here are some functions, along with a batch file, showing how to determine
whether your processor supports certain instruction sets;

Code:
@setlocal
@echo off
function SSE=`%@winapi[cpuid,SSE_IsSupported]`
function SSE42=`%@winapi[cpuid,SSE42_IsSupported]`
function MMX=`%@winapi[cpuid,MMX_IsSupported]`
function HTT=`%@winapi[cpuid,HTT_IsSupported]`

iff %@SSE[] eq 1 then
   echo Your Processor Supports SSE
else
  echo Your Processor Does Not Support SSE
endiff

iff %@SSE42[] eq 1 then
  echo Your Processor Supports SSE42
else
  echo Your Processor Does Not Support SSE42
endiff

iff %@MMX[] eq 1 then
  echo Your Processor Supports MMX
else
  echo Your Processor Does Not Support MMX
endiff

iff %@HTT[] eq 1 then
  echo Your Processor Supports HTT
else
  echo Your Processor Does Not Support HTT
endiff
endlocal
This works on;

Code:
TCC 11.00.39 Windows XP [Version 5.1.2600]
TCC Build 39 Windows XP Build 2600 Service Pack 3
Joe
 
CPUID

THIS FAILS mainly because it has no DLL specified atlas cpuid is not a known DLL on my
system.

----- Original Message -----
From: "Joe Caverly"
Sent: Sunday, February 21, 2010 3:12 AM
Subject: [T&T - Functions-t-1750] CPUID



> Here are some functions, along with a batch file, showing how to determine
> whether your processor supports certain instruction sets;
>
>
> Code:
> ---------
> @setlocal
> @echo off
> function SSE=`%@winapi[cpuid,SSE_IsSupported]`
> function SSE42=`%@winapi[cpuid,SSE42_IsSupported]`
> function MMX=`%@winapi[cpuid,MMX_IsSupported]`
> function HTT=`%@winapi[cpuid,HTT_IsSupported]`
>
> iff %@SSE[] eq 1 then
> echo Your Processor Supports SSE
> else
> echo Your Processor Does Not Support SSE
> endiff
>
> iff %@SSE42[] eq 1 then
> echo Your Processor Supports SSE42
> else
> echo Your Processor Does Not Support SSE42
> endiff
>
> iff %@MMX[] eq 1 then
> echo Your Processor Supports MMX
> else
> echo Your Processor Does Not Support MMX
> endiff
>
> iff %@HTT[] eq 1 then
> echo Your Processor Supports HTT
> else
> echo Your Processor Does Not Support HTT
> endiff
> endlocal
> ---------
> This works on;
>
>
> Code:
> ---------
> TCC 11.00.39 Windows XP [Version 5.1.2600]
> TCC Build 39 Windows XP Build 2600 Service Pack 3
> ---------
> Joe
>
>
>
>
 
CPUID

I simplified the BTM to when it only reports:

--- code ---
@echo off
setlocal
echo Your Processor Supports SSE: %@if[%@winapi[cpuid,SSE_IsSupported]
EQ 1,yes,no]
echo Your Processor Supports SSE42: %@if[%@winapi[cpuid,SSE42_IsSupported]
EQ 1,yes,no]
echo Your Processor Supports MMX: %@if[%@winapi[cpuid,MMX_IsSupported]
EQ 1,yes,no]
echo Your Processor Supports HTT: %@if[%@winapi[cpuid,HTT_IsSupported]
EQ 1,yes,no]

--- end code ---

However, it fails here as well with the message "The specified module could
not be found" - "cpuid".

Software Environment:
TCC 11.00.40 Windows XP [Version 5.1.2600]
TCC Build 40 Windows XP Build 2600 Service Pack 3

Hardware (from %_cpu): AMD Athlon(tm) XP 2100+ - x86 Family 6 Model 6
Stepping 2(Athlon XP) @ 1733 MHZ - Palomino/Corvette
(0000-0662-0383-FBFF-0000-0000)
--
Steve
 
[/CODE]This works on;

Code:
TCC 11.00.39 Windows XP [Version 5.1.2600]
TCC Build 39 Windows XP Build 2600 Service Pack 3
Joe

Well, I've got that DLL on three of my systems, and have been calling it from some PowerBASIC Programs I've written.

It's dated 12/20/2009, is 6,144 bytes in size, and has no entries in the summary fields. It only has those four functions.

I have a feeling I may have written it, but darned if I can find the source code for it!:confused:

I did find the source code for a CPUID.EXE, which has similar functions, which I was working on last December, on exactly that date. It should not be too difficult for me to re-create the DLL.

Sorry for the confusion.:o

Joe
 
It should not be too difficult for me to re-create the DLL.

Joe

Well, I found the source code, nicely backed up on my NAS Drive.

I've compiled the PowerBASIC code, and have attached the DLL.

Again, sorry for the confusion.:o

It would appear that I'm starting to get mighty forgetful in my old age.:(

I did find in the comments the link to the Intel Docs I was working from, if anyone is interested in the details.

Joe
 

Attachments

  • cpuid.zip
    2.4 KB · Views: 261
| ---Quote (Originally by Joe Caverly)---
|| It should not be too difficult for me to re-create the DLL.
| ---End Quote---
| Well, I found the source code, nicely backed up on my NAS Drive.
|
| I've compiled the PowerBASIC code, and have attached the DLL.

Inasmuch as you (and only you) have the source code, you might just make it
into a plug-in DLL, defining four internal variables (which can be evaluated
once during the loading of the plug-in, since the hardware won't change),
using the usual 0 / 1 values:
_SSE_Supported
_SSE42_Supported
_MMX_Supported
_HTT_Supported
--
Steve
 
Joe,

Since you had to create a DLL for this function anyway, why not make it a
plugin instead? That way you don't have to create FUNCTION's on top of
the DLL.

There are a number of ways you could implement the plugin's interface.
Here are a few that come to mind:

1) create variables for each "thing" :
_SSE_Supported
_SSE42_Supported
_MMX_Supported
_HTT_Supported

2) Create a function similar to how @SHFOLDER works:
@CPUID[index]
index can be:
0 - SSE Supported
1 - SSE42 Supported
2 - MMX Supported
3 - HTT Supported
4 - HW Virtualization Supported
5 - etc.

For option 2 you'd use it like:
if %@cpuid[0] == 1 (echo SSE Supported) else (echo SSE not
supported)

-Scott


Joe Caverly <> wrote on 02/20/2010 08:22:29
PM:


> ---Quote (Originally by Joe Caverly)---
> It should not be too difficult for me to re-create the DLL.
>
> Joe
> ---End Quote---
> Well, I found the source code, nicely backed up on my NAS Drive.
>
> I've compiled the PowerBASIC code, and have attached the DLL.
>
> Again, sorry for the confusion.:o
>
> It would appear that I'm starting to get mighty forgetful in my old
age.:(

>
> I did find in the comments the link to the Intel Docs
> intel.
>
com/software/products/documentation/vlin/mergedprojects/analyzer_ec/mergedprojects/reference_olh/mergedprojects/instructions/instruct32_hh/vc46.

> htm) I was working from, if anyone is interested in the details.
>
> Joe
>
> Attached to this message is cpuid.zip
>
>
>
>
 
| ---Quote (Originally by Steve Fbin)---
|| you might just make it
|| into a plug-in DLL,
| ---End Quote---
| Continued at http://www.jpsoft.com/forums/showthread.php?t=1751

Not accessible by email. Hyperlink enters browser without logging in, even
when another Firefox tab is already logged in. In which NG / subforum is
that continuation located? Can you either upload the new plug-in or provide
an accessible ftp or http URL?
--
Steve
 
Back
Top