_CPUID, CPUIDD & _CPUID$ Functions

Purpose

Global variables which return information about the processor.

Syntax

a = _CPUID
a = _CPUIDD
c$ = _CPUID$

a: large variable
c$: string variable

Description

Each of these functions return specific information from internal registers, _CPUID returning Highest Function Parameter and Manufacturer ID information, _CPUIDD Processor Info and Feature Bits, while _CPUID$ returns the type of the processor.

An example of information that can be extracted from _CPUID: Show

An exmaple of information that can be extracted from _CPUIDD: Show

For more details of the type of information returned see here.

Example

OpenW 1

Print _CPUID$                           // Returns the type of processor

Print Btst(_CPUIDD, 0)                  // True if the processor contains a FPU (should always be TRUE these days)

Print (_CPUID And $3000)                // Returns CPU type (usually 0 - Normal CPU)

Print (_CPUID And $0FFF)                // Returns the CPU type

Do : Sleep : Until Me Is Nothing

Remarks

The global variables _CPUID$, _CPUID, and _CPUIDD are initialized at startup. The compiler does not generate a cpuid assembler instruction, but instead generates code to read these global variables. To initialize these global variables the cpuid instruction is invoked with different 'input parameters'. To obtain specific information from the CPU the eax register must be set to the proper input value prior to using cpuid. The retrieved information using cpuid is returned in the eax, ebx, ecx, and edx registers. The _CPUID$ value is obtained by setting eax = 0 before invoking cpuid. The CPU stores the twelve-character ASCII string in ebx, edx, ecx (in that order), which is then copied to _CPUID$. The value stored in eax is ignored. The 32-bit integer global variables _CPUID and _CPUIDD return information when the input parameter eax = 1. The return value in eax specifies the signature of the CPU and is stored in _CPUID. The return value in edx specifies the feature flags and is stored in _CPUIDD.

See Also

{Created by Sjouke Hamstra; Last updated: 20/11/2021 by James Gaite}