    CHKCPU
    03/03/2000
    by Jan Steunebrink  < http://web.inter.nl.net/hcc/J.Steunebrink >

    CPU Identification utility v1.6
    -------------------------------

Introduction
------------
After a CPU and/or motherboard upgrade, it can be difficult to find the
correct motherboard jumper settings for clockspeed, CPU multiplication factor,
and (for 486 only) internal cache Write-Back/Write-Through mode selection.
I wrote this utility to have an easy check on these settings.


The program
-----------
The program comes in a ZIP-file (CHKCPU16.ZIP) which should contain the
following 2 files: CHKCPU.EXE  ;the program
                   CHKCPU.TXT  ;this text file.
The files have a date-time stamp of 03/03/00 - 1:06 am.
The program is written in assembly language and it is freeware.

The program is started by typing CHKCPU at the command prompt.
CHKCPU can be run from the DOS prompt or from a DOS-box within Windows.
However, on 486 class CPUs, accurate speed indications cannot be obtained
when the L1 cache is disabled.

CHKCPU uses the motherboard's Timer 2 to time the CPU speed.
CHKCPU gives the same speed indication accuracy when run under Windows 3.x/9x
(in 'Protected mode') compared to the 'Real mode' DOS environment.
Under Windows NT/2000 however, the direct hardware access to Timer 2 is
virtualized which gives an approximately 10% too low speed reading.
The behavior of CHKCPU under OS/2 is unknown.
So generally, I recommend running CHKCPU after a clean boot to DOS, without
an expanded memory manager (EMM386 or QEMM) loaded.


On my upgraded 486 PC, the program displays the following information:

 CPU Identification utility v1.6                  (c) 1997-2000 Jan Steunebrink
 
 CPU Vendor and Model: AMD 5x86-133 P75 (X5) in 4x clock mode
 Internal CPU speed  : 132.9 MHz
 CPU-ID Vendor string: AuthenticAMD
 CPU-ID Signature    : 04F4
                        Stepping or sub-model no.
                        Model: Indicates CPU Model and 486 L1 cache mode
                        Family: 4=486, Am5x86, Cx5x86
                                  5=Pentium, Nx586, Cx6x86, K5/K6, C6, mP6
                                  6=PentiumPro/II/III, Cx6x86MX, Athlon
                        Type: 0=Standard, 1=Overdrive, 2=2nd Dual Pentium
 Current CPU mode    : Virtual
 Internal (L1) cache : Enabled in Write-Back mode

On another upgraded PC, with a Cyrix M2 PR233 CPU, I got:

 CPU Identification utility v1.6                  (c) 1997-2000 Jan Steunebrink
 
 CPU Vendor and Model: Cyrix/IBM 6x86MX (M2) in 3.0x clock mode
 Internal CPU speed  : 200.4 MHz  (using internal Time Stamp Counter)
 CPU-ID Vendor string: CyrixInstead
 CPU-ID Signature    : 0600
                        Stepping or sub-model no.
                        Model: Indicates CPU Model and 486 L1 cache mode
                        Family: 4=486, Am5x86, Cx5x86
                                  5=Pentium, Nx586, Cx6x86, K5/K6, C6, mP6
                                  6=PentiumPro/II/III, Cx6x86MX, Athlon
                        Type: 0=Standard, 1=Overdrive, 2=2nd Dual Pentium
 Cyrix Device Id Regs: DIR0: 53h  CPU Model
                       DIR1: 07h  CPU Step and Revision
 Current CPU mode    : Real
 Internal (L1) cache : Enabled in Write-Back mode

And running CHKCPU under Win98 on a laptop with an Intel Celeron 300a:

 CPU Identification utility v1.6                  (c) 1997-2000 Jan Steunebrink
 
 CPU Vendor and Model: Intel Celeron-A 300/333/366/400 A0-step
 Internal CPU speed  : 300.7 MHz  (using internal Time Stamp Counter)
 CPU-ID Vendor string: GenuineIntel
 CPU-ID Signature    : 0660
                        Stepping or sub-model no.
                        Model: Indicates CPU Model and 486 L1 cache mode
                        Family: 4=486, Am5x86, Cx5x86
                                  5=Pentium, Nx586, Cx6x86, K5/K6, C6, mP6
                                  6=PentiumPro/II/III, Cx6x86MX, Athlon
                        Type: 0=Standard, 1=Overdrive, 2=2nd Dual Pentium
 Current CPU mode    : Protected
 Internal (L1) cache : Enabled in Write-Back mode

Apart from this 'Normal' display, CHKCPU supports command-line switches to
get another format or to display additional CPU information.
You can get a list of these switches with the command CHKCPU /? or /H
The following switches are supported:
- With CHKCPU /D you get the Debug mode. It displays a dump of raw OS and
  CPUID level information. I added this mode to make troubleshooting
  problems with CHKCPU easier.
- With CHKCPU /I you force the use of the Instruction timing method for CPU
  speed measurement. Useful if the TSC method gives an incorrect reading.
- With CHKCPU /R you force the use of Real (or Virtual) mode. Protected
  mode via the DOS Protected Mode Interface is then not used.
- With CHKCPU /S you get a Short display of CPU Type and Speed only.
  Intended for use in network logon scripts. This mode has no trailing CR.
- With CHKCPU /V you get the Verbose mode. It displays additional CPUID info
  like CPU features and the sizes of the L1 and integrated L2 cache.
  For CPUs with split Data/Instruction L1 caches, the combined value is shown.
  Some CPU features are only displayed for specific CPUs. These are:
   'AMD MMX extensions' and 'AMD 3DNow! extensions' for K6 and higher, and
   'CPU Serial Number Enabled' for the PentiumIII.
  The CPU features and the sizes of the L1 and L2 cache, are all derived from
  the CPU-ID information.
Switches can be combined. Example: CHKCPU /S /I gives a short display,
without the use of the Time Stamp Counter.
The /S switch has priority over the /D and /V switches, and the /D switch
has priority over the /V switch.


CHKCPU recognizes any 386 or higher CPU, however detailed information can
only be displayed for CPUs which support the CPUID instruction or
Cyrix CPUs with Device Identification Register (DIR) support.
This covers some 486 and all 586/Pentium and higher CPUs.
The program recognizes CPUs from Intel, AMD, NexGen, Cyrix/IBM, UMC, IDT,
and Rise.
If the program is run on a 386 or (non-Cyrix) 486 CPU without CPUID support,
the CPU will be indicated as a 'classic' 386 or 'classic' 486 and a shortened
display with only speed and (if present) cache information will follow.

On Cyrix CPUs, the CPUID instruction can be disabled via a CPU configuration
register. On some PCs the BIOS disables CPUID during boot-up. CHKCPU checks
for this condition and enables CPUID again. All other Cyrix CPU configuration
registers that CHKCPU uses are restored to their previous state.

On IDT CPUs, the CPUID Vendor string and Signature can be programmed to any
value. CHKCPU checks for this condition and temporarily disables this
programming to show the real Vendor string and Signature of these CPUs.
However, this check can only be done in 'Real mode' and is therefore skipped
if the CPU is in 'Virtual or Protected mode' (EMM386, Windows).

The Internal CPU speed display accuracy is at its best if the program is run
with the CPU internal (Level 1) cache enabled.
An 'attention' message is displayed if this condition is not met.
The CPU speed is measured by accurately timing the execution of a bunch of
slow 'Divide' instructions.
For Pentium class CPUs however, the internal Time Stamp Counter (TSC) is used
whenever possible to further improve the accuracy of the speed measurement.
A message behind the CPU speed display indicates if the TSC is used.
As using the TSC would crash the program when the CPU is in 'Virtual mode',
the CPU speed measurement switches back to the (less accurate) instruction
timing method when the CPU is not in 'Real or Protected mode'.
When the program runs in 'Protected mode' but not under Win 3.x/95/98, it
also switches to the instruction timing method to avoid problems with
Windows NT/2000.


Error and Unknown messages
--------------------------
CHKCPU has to use a lot of 32-bit instructions. If the program is run
on a 16-bit CPU like the 8086/88, 80186/88, or 80286 you will see:
 ERROR: This program requires a 386 or higher CPU!
Note: If the /s option is used, you only see: No 386+

If CHKCPU is unable to detect the CPU Vendor you get an "Unknown" indication.
If CHKCPU is unable to detect the CPU Model you'll see -Unknown model-.

If a Cyrix CPU is detected but no DIR support is found you get:
 Cyrix Device Id Regs: - DIR registers could not be found -
This is correct on the early Cx486 CPUs but most Cx486 and all Cx5x86 and
later Cyrix CPUs should support the Device Identification Registers.

On 386 and 486 CPUs without CPUID support you'll get:
 CPU-ID Vendor string: - No CPUID -


Internal CPU speed
------------------
Since the Intel 486DX2 hit the market, most CPUs run internally faster
than externally.
The Internal CPU speed display indicates the true internal CPU clock speed.
The internal CPU clock speed = Bus clock X multiplication factor.
The Bus clock is the speed of the motherboard clock.
486 boards are normally selectable at 25, 33.3, 40, 50, and 60 (some) MHz and
Pentium boards at 50, 60, 66.6, 75, 83.3, 95.2, 100, and 112 (some) MHz.
The newest boards also support 133 MHz busspeed.
The selectable multiplication factor depends on the CPU and can be anything
upto x8 but factors above x3.5 are only found on newer CPUs.
On Pentium class CPUs, the multiplication factor is usually selectable in
steps of 0.5 (x1.5, x2, x2.5, x3 etc.). 
Some CPUs have a fixed multiplication factor, and some use fractional factors
like x1.75 (K5) or x2.33 (Winchip-2A).

For Intel CPUs the internal speed equals the rating. So a Pentium 200 will
run internally at 200 MHz. (66.6 x 3)
For AMD, Cyrix, and Rise CPUs the internal speed can be lower than the PR
rating due newer and more efficient design.
For the K6-2 and later AMD CPUs, the internal speed equals the rating again.


Internal (L1) cache
-------------------
The program detects if the internal (Level 1) cache is disabled or enabled.
If enabled, the program indicates if the cache operates in the Write-Through
(read only cache) or Write-Back (read and write cache) mode.
For the 486 CPU family, this information is derived from the CPU-ID signature,
except for Cyrix CPUs where it is taken from Configuration Control Register #2
(C2h) bit 1 (WBAK - Write Back Cache Interface Pins Enable).

Except for the Nx586 and the Intel Pentium 63/83 ODP (P24T), the Pentium
and higher CPU families always operate their L1 cache in Write-Back mode.
The Nx586 has only Write-Through mode and is indicated as such.
The P24T can operate in either the Write-Through or Write-Back mode.
For this CPU, CHKCPU uses a special routine to detect the difference.
However, the CPU needs to be in 'Real mode' to be able to check the L1 cache
mode for both the Nx586 and the P24T.
This check is therefore skipped if these CPUs are not running in 'Real mode'.


Acknowledgments
---------------
I could not have written this program without the hard work of these people:
- Christian Ludloff http://www.sandpile.org/80x86/ for his unsurpassed amount
  and detail of CPU information.
- Grzegorz Mazur http://grafi.ii.pw.edu.pl/gbm/x86/ for publishing the basic
  algorithms for CPU detection.
- Frank van Gilluwe, author of "The Undocumented PC" (second edition); still
  my favorite hardware book.
  The internal CPU speed detection routine according the instruction timing
  method is based on ideas from his book.


Feedback requested
------------------
If you encounter an "Unknown" message or if you have any questions regarding
this program, please send me an E-mail with your CPU details and
the CHKCPU /D and CHKCPU /V outputs.
You can use the redirect function of DOS to get the output in a file.
E.g. CHKCPU /D > MYCPU-D.TXT and CHKCPU /V > MYCPU-V.TXT

J.Steunebrink@net.HCC.nl

------------------------------------------------------------------------------
Chkcpu revision history:

Version 1.6
03/03/2000
- Updated the CPU data for new AMD K6-2, AMD Athlon, and Intel Celeron models,
  and added support for the Intel PentiumIII-E (Coppermine).
- Fixed the 45% too low speed reading on the AMD Athlon when the TSC is not
  used. (instruction timing method).
- Increased the accuracy of the CPU speed measurement for fast CPUs, like the
  AMD K6-2/III, Athlon, and Intel Celeron/PentiumII/III(-E).
- Rewritten the basic CPU detection algorithm for better detection of NexGen,
  Cyrix, and IDT CPUs. This algorithm works also in Virtual and Protected mode.
- Added support for 386 and (non-Cyrix) 486 CPUs which do not know the CPUID
  instruction. CHKCPU will no longer abort with an error on these CPUs.
- Fixed a bug that crashed CHKCPU in Real mode on a Nx586, and fixed
  the L1 cache mode detection on this CPU.
- Changed the logic for the command-line switches so that in case of an
  unrecognized option, the display defaults to the Short mode. In addition,
  the command-line switches will also work if the space between CHKCPU and
  the command-line switch, or between the switches, is omitted.
- The speed reading in Short mode is now rounded off and displayed in
  whole MHz.

Version 1.5
09/09/99
- Updated the CPU data for new AMD K6-2, Intel Celeron, PentiumIII, and
  IDT Winchip steppings, and added the AMD Athlon (K7).
- Fixed a bug where an IDT CPU was displayed as an "IDT Rise -Unknown model-".
- Added support for Command line switches. You can get a list with CHKCPU /?
- An Intel Celeron CPU is now indicated as such. CHKCPU v1.5 is able to
  differentiate between a PentiumII and a Celeron with the same signature.
- Moved the integrated L2 cache size display to the Verbose mode, because it
  is no longer required for visual differentiation between a PentiumII and
  a Celeron.
- Added display of various CPU features. (Verbose mode only)
- Added display of the L1 cache size. (Verbose mode only)

Version 1.4
04/04/99
- Updated the CPU data with the new AMD K6-2 (CTX-core), K6-III,
  Intel PentiumII/Celeron, and PentiumIII steppings.
- Added support for the Rise mP6 CPU.
- Added display of the amount of integrated L2 cache on the PentiumPro/II/III,
  AMD K6-III, and Cyrix M3 CPUs. For the Intel PentiumII an additional
  'Celeron or Celeron-A type' indication is added when appropriate.
- Rewritten the program so that it runs in (16-bit) Protected mode whenever a
  DOS Protected Mode Interface (DPMI) host is present. (Windows, OS/2, etc.)
  This improves the speed display accuracy in the DOS-box for all CPUs and in
  addition, under Windows 3.x/95/98 on the Pentium class CPUs, the internal
  Time Stamp Counter can now be used, just as in Real mode.
- Added display of the Current CPU mode: Real, Virtual, or Protected.

Version 1.3
12/12/98
- Updated the CPU data. The new AMD K6-2, IDT C6-2, and Intel PentiumII/
  Celeron/Xeon steppings are now supported.
- Added a new Internal speed detection routine for all CPUs that support the
  Pentium Time Stamp Counter. This results in a more accurate speed display,
  especially on non-Intel CPUs (only in Real mode).
- Made the program better usable under Windows by adding checks for
  protected mode before using 'restricted' instructions.
  This avoids triggering a General Protection Fault.
- Fixed a bug where the program was aborted by Windows if run on a 386
  or (non-Cyrix) 486 CPU without CPUID support.

Version 1.2
04/04/98
- Updated the CPU data. The new Pentium II 333 (Deschutes) is now supported.
- Fixed the Intel Pentium Pro detection. CHKCPU v1.1 indicated these CPUs as
  a "Cyrix -Unknown model-".

Version 1.1
02/02/98 First update.
- Updated the CPU data.
- Added CPU multiplication factor indication for the Cx486DX4 and AMD K5.
- Expanded the internal CPU speed display with a decimal.
- Updated the internal cache mode detection for early Cyrix/TI CPUs.
- Fixed the Intel Pentium 63/83 ODP (P24T) internal cache mode detection.
  CHKCPU v1.0 indicated the internal cache mode of the P24T always as WB.
  This is not correct as the P24T can also operate in WT mode.
  For this CPU, a routine has been added to detect the difference.

Version 1.0
12/12/97 First release.
------------------------------------------------------------------------------

