📄 cpu.pas
字号:
BinArray:array[0..31] of byte;
i,p:integer;
begin
asm
push eax
push ebx
push ecx
push edx
mov eax,$80000005
mov ebx,0
mov ecx,0
mov edx,0
db $0F,$A2 /// cpuid
mov L1I,edx
pop edx
pop ecx
pop ebx
pop eax
end;
for i:=0 to 31 do
begin
BinArray[i]:=L1I mod 2;
L1I:=L1I div 2;
end;
TempL1I:=0;
p:=0;
for i:=24 to 31 do
begin
TempL1I:=TempL1I+(BinArray[i]*StrToInt(FloatToStr(Power(2,p))));
inc(p);
end;
GetExtendedL1ICache:=TempL1I;
end;
function TCpuData.GetExtendedL2Cache:word;
var L2,TempL2:dword;
BinArray:array[0..31] of byte;
i,p:integer;
begin
asm
push eax
push ebx
push ecx
push edx
mov eax,$80000006
mov ebx,0
mov ecx,0
mov edx,0
db $0F,$A2 /// cpuid
mov L2,ecx
pop edx
pop ecx
pop ebx
pop eax
end;
for i:=0 to 31 do
begin
BinArray[i]:=L2 mod 2;
L2:=L2 div 2;
end;
TempL2:=0;
p:=0;
for i:=16 to 31 do
begin
TempL2:=TempL2+(BinArray[i]*StrToInt(FloatToStr(Power(2,p))));
inc(p);
end;
GetExtendedL2Cache:=TempL2;
end;
function TCpuData.CheckCeleron:Boolean;
var BId:byte;
begin
asm
push eax
push ebx
push ecx
push edx
mov eax,1
db $0F,$A2 /// cpuid
mov BId,bl
pop edx
pop ecx
pop ebx
pop eax
end;
CheckCeleron:=(BId=$1);
end;
function TCpuData.CheckPentiumIII:Boolean;
var BId:byte;
begin
if CheckMMX and CheckSSE then CheckPentiumIII:=True
else CheckPentiumIII:=False;
end;
function TCpuData.CheckXeon:Boolean;
var BId:byte;
begin
asm
push eax
push ebx
push ecx
push edx
mov eax,1
db $0F,$A2 /// cpuid
mov BId,bl
pop edx
pop ecx
pop ebx
pop eax
end;
CheckXeon:=(BId=$3);
end;
function TCpuData.CheckPentium4:Boolean;
var BId:byte;
begin
asm
push eax
push ebx
push ecx
push edx
mov eax,1
db $0F,$A2 /// cpuid
mov BId,bl
pop edx
pop ecx
pop ebx
pop eax
end;
CheckPentium4:=(BId=$8);
end;
function TCpuData.CheckIthanium:Boolean;
var res:dword;
BinArray:array[0..31] of byte;
i:byte;
begin
asm
push eax
push ebx
push ecx
push edx
mov eax,1
db $0F,$A2 /// cpuid
mov res,edx
pop edx
pop ecx
pop ebx
pop eax
end;
for i:=0 to 31 do
begin
BinArray[i]:=res mod 2;
res:=res div 2;
end;
CheckIthanium:=(CheckPentium4 and (BinArray[30]=1));
end;
function TCpuData.IntelP5N:string;
begin
If CheckMMX then IntelP5N:='Intel Pentium(r) MMX(tm)'
else IntelP5N:='Intel Pentium(r)';
end;
function TCpuData.IntelP6N:string;
begin
if CheckCeleron then IntelP6N:='Intel Celeron(r)'
else
if CheckPentiumIII then IntelP6N:='Intel Pentium(r) III'
else
if CheckXeon then IntelP6N:='Intel Pentium(r) III Xeon(tm)'
else
if not CheckMMX then IntelP6N:='Intel Pentium(r) PRO'
else IntelP6N:='Intel Pentium(r) II';
end;
function TCpuData.AMDK5N:string;
var Family,Model,Stepping:byte;
begin
GetFMS(Family,Model,Stepping);
if Model=0 then AMDK5N:='AMD K5'
else AMDK5N:=GetExtendedCpuName;
end;
function TCpuData.Cyrix686N:string;
begin
if CpuData.GetMaxExtendedFunctions>0 then Cyrix686N:=GetExtendedCpuName
else
if CheckMMX then Cyrix686N:='VIA Cyrix 6x86MII'
else
Cyrix686N:='VIA Cyrix 6x86';
end;
function TCpuData.GenericCpuN:string;
var SysInfo:TSystemInfo;
begin
GetSystemInfo(SysInfo);
if SysInfo.dwProcessorType=386
then GenericCpuN:='Generic 386 CPU'
else
if SysInfo.dwProcessorType=486
then GenericCpuN:='Generic 486 CPU'
else
if SysInfo.dwProcessorType=586
then GenericCpuN:='Pentium Class CPU'
else GenericCpuN:='Unknown CPU';
end;
function TCpuData.P5CacheL1DI:word;
begin
if CheckMMX then P5CacheL1DI:=16
else P5CacheL1DI:=8;
end;
function TCpuData.P6CacheL1DI:word;
begin
if not CheckMMX then P6CacheL1DI:=8
else P6CacheL1DI:=16;
end;
function TCpuData.P6CacheL2:word;
var Family,Model,Stepping:byte;
begin
if CheckCeleron then P6CacheL2:=128
else
if CheckPentiumIII then begin
GetFMS(Family,Model,Stepping);
if Model=7 then P6CacheL2:=512
else if Model=8 then P6cacheL2:=256
else P6CacheL2:=512;
end
else if not CheckMMX then P6CacheL2:=512
else P6CacheL2:=512;
end;
function TCpuData.AuthenticAMD:TCpuRec;
var Family,Model,Stepping:byte;
EFamily,EModel,EStepping:byte;
begin
GetFMS(Family,Model,Stepping);
If Family=4 then begin
AuthenticAMD.Name:='AMD 486';
AuthenticAMD.Vendor:=GetVendorString;
AuthenticAMD.Frequency:=0;
AuthenticAMD.Family:=Family;
AuthenticAMD.Model:=Model;
AuthenticAMD.Stepping:=Stepping;
AuthenticAMD.L1DCache:=8;
AuthenticAMD.L1ICache:=8;
AuthenticAMD.L2Cache:=0;
end
else
if Family=5 then begin
if GetMaxExtendedFunctions>4 then
begin
AuthenticAMD.Name:=GetExtendedCpuName;
AuthenticAMD.Vendor:=GetVendorString;
AuthenticAMD.Frequency:=GetCPUFrequency;
GetExtendedFMS(EFamily,EModel,EStepping);
AuthenticAMD.Family:=EFamily;
AuthenticAMD.Model:=EModel;
AuthenticAMD.Stepping:=EStepping;
AuthenticAMD.L1DCache:=GetExtendedL1DCache;
AuthenticAMD.L1ICache:=GetExtendedL1ICache;
AuthenticAMD.L2Cache:=0;
end
else
begin
AuthenticAMD.Name:=AMDK5N;
AuthenticAMD.Vendor:=GetVendorString;
AuthenticAMD.Frequency:=GetCPUFrequency;
AuthenticAMD.Family:=Family;
AuthenticAMD.Model:=Model;
AuthenticAMD.Stepping:=Stepping;
AuthenticAMD.L1DCache:=16;
AuthenticAMD.L1ICache:=16;
AuthenticAMD.L2Cache:=0;
end;
end
else if family>5 then
begin
AuthenticAMD.Name:=GetExtendedCpuName;
AuthenticAMD.Name:=GetExtendedCpuName;
AuthenticAMD.Vendor:=GetVendorString;
AuthenticAMD.Frequency:=GetCPUFrequency;
GetExtendedFMS(EFamily,EModel,EStepping);
AuthenticAMD.Family:=EFamily;
AuthenticAMD.Model:=EModel;
AuthenticAMD.Stepping:=EStepping;
AuthenticAMD.L1DCache:=GetExtendedL1DCache;
AuthenticAMD.L1ICache:=GetExtendedL1ICache;
AuthenticAMD.L2Cache:=GetExtendedL2Cache;
end;
end;
function TCpuData.GenuineIntel:TCpuRec;
var Family,Model,Stepping:byte;
begin
GetFMS(Family,Model,Stepping);
if Family=4 then begin
GenuineIntel.Name:='Intel 486';
GenuineIntel.Vendor:=GetVendorString;
GenuineIntel.Frequency:=0;
GenuineIntel.Family:=Family;
GenuineIntel.Model:=Model;
GenuineIntel.Stepping:=Stepping;
GenuineIntel.L1DCache:=8;
GenuineIntel.L1ICache:=8;
GenuineIntel.L2Cache:=0;
end
else
if Family=5 then begin
GenuineIntel.Name:=IntelP5N;
GenuineIntel.Vendor:=GetVendorString;
GenuineIntel.Frequency:=GetCPUFrequency;
GenuineIntel.Family:=Family;
GenuineIntel.Model:=Model;
GenuineIntel.Stepping:=Stepping;
GenuineIntel.L1DCache:=P5CacheL1DI;
GenuineIntel.L1ICache:=P5CacheL1DI;
GenuineIntel.L2Cache:=0;
end
else
if Family=6 then begin
GenuineIntel.Name:=IntelP6N;
GenuineIntel.Vendor:=GetVendorString;
GenuineIntel.Frequency:=GetCPUFrequency;
GenuineIntel.Family:=Family;
GenuineIntel.Model:=Model;
GenuineIntel.Stepping:=Stepping;
GenuineIntel.L1DCache:=P6CacheL1DI;
GenuineIntel.L1ICache:=P6CacheL1DI;
GenuineIntel.L2Cache:=P6CacheL2;
end
else
if Family=$F then begin
if CheckPentium4 then
begin
GenuineIntel.Name:='Intel Pentium(r) 4';
GenuineIntel.Vendor:=GetVendorString;
GenuineIntel.Frequency:=GetCPUFrequency;
GenuineIntel.Family:=32;
GenuineIntel.Model:=Model;
GenuineIntel.Stepping:=Stepping;
GenuineIntel.L1DCache:=8;
GenuineIntel.L1ICache:=12;
GenuineIntel.L2Cache:=256;
end
else if CheckIthanium then
begin
GenuineIntel.Name:='Intel Ithanium';
GenuineIntel.Vendor:=GetVendorString;
GenuineIntel.Frequency:=GetCPUFrequency;
GenuineIntel.Family:=64;
GenuineIntel.Model:=Model;
GenuineIntel.Stepping:=Stepping;
GenuineIntel.L1DCache:=0;
GenuineIntel.L1ICache:=0;
GenuineIntel.L2Cache:=0;
end;
end;
end;
function TCpuData.CyrixInstead:TCpuRec;
var Family,Model,Stepping:byte;
EFamily,EModel,EStepping:byte;
begin
GetFMS(Family,Model,Stepping);
if Family=4 then begin
CyrixInstead.Name:='VIA Cyrix 4x86';
CyrixInstead.Vendor:=GetVendorString;
CyrixInstead.Frequency:=0;
CyrixInstead.Family:=Family;
CyrixInstead.Model:=Model;
CyrixInstead.Stepping:=Stepping;
CyrixInstead.L1DCache:=8;
CyrixInstead.L1ICache:=8;
CyrixInstead.L2Cache:=0;
end
else
if Family=5 then begin
CyrixInstead.Name:='VIA Cyrix 5x86';
CyrixInstead.Vendor:=GetVendorString;
CyrixInstead.Frequency:=GetCPUFrequency;
CyrixInstead.Family:=Family;
CyrixInstead.Model:=Model;
CyrixInstead.Stepping:=Stepping;
CyrixInstead.L1DCache:=8;
CyrixInstead.L1ICache:=8;
CyrixInstead.L2Cache:=0;
end
else begin
if GetMaxExtendedFunctions>0 then
Begin
CyrixInstead.Name:=GetExtendedCpuName;
CyrixInstead.Vendor:=GetVendorString;
CyrixInstead.Frequency:=GetCPUFrequency;
GetExtendedFMS(EFamily,EModel,EStepping);
CyrixInstead.Family:=EFamily;
CyrixInstead.Model:=EModel;
CyrixInstead.Stepping:=EStepping;
CyrixInstead.L1DCache:=GetExtendedL1DCache;
CyrixInstead.L1ICache:=GetExtendedL1ICache;
CyrixInstead.L2Cache:=GetExtendedL2Cache;
end
else begin
CyrixInstead.Name:=Cyrix686N;
CyrixInstead.Vendor:=GetVendorString;
CyrixInstead.Frequency:=GetCPUFrequency;
CyrixInstead.Family:=Family;
CyrixInstead.Model:=Model;
CyrixInstead.Stepping:=Stepping;
CyrixInstead.L1DCache:=32;
CyrixInstead.L1ICache:=32;
CyrixInstead.L2Cache:=0;
end;
end;
end;
function TCpuData.GenericCPU:TCpuRec;
var Family,Model,Stepping:byte;
EFamily,EModel,EStepping:byte;
begin
if not GetCPUIDSupport then
begin
MessageDlg('This CPU does not support the CPUID instruction!!!',mtWarning,
[mbOk],0);
GenericCPU.Name:='Unidentified CPU';
GenericCPU.Vendor:='Unidentified';
GenericCPU.Frequency:=0;
GenericCPU.Family:=-1;
GenericCPU.Model:=-1;
GenericCPU.Stepping:=-1;
GenericCPU.L1DCache:=0;
GenericCPU.L1ICache:=0;
GenericCPU.L2Cache:=0;
end
else
begin
GetFMS(Family,Model,Stepping);
if GetMaxExtendedFunctions>0 then
begin
GenericCPU.Name:=GetExtendedCPUName;
GenericCPU.Vendor:=GetVendorString;
GenericCPU.Frequency:=GetCPUFrequency;
CpuData.GetExtendedFMS(EFamily,EModel,EStepping);
GenericCPU.Family:=EFamily;
GenericCPU.Model:=EFamily;
GenericCPU.Stepping:=EStepping;
GenericCPU.L1DCache:=GetExtendedL1DCache;
GenericCPU.L1ICache:=GetExtendedL1ICache;
GenericCPU.L2Cache:=GetExtendedL2Cache;
end
else begin
GenericCPU.Name:=GenericCpuN;
GenericCPU.Vendor:=GetVendorString;
if Family<=4 then GenericCPU.Frequency:=0
else GenericCPU.Frequency:=GetCPUFrequency;
GenericCPU.Family:=Family;
GenericCPU.Model:=Model;
GenericCPU.Stepping:=Stepping;
GenericCPU.L1DCache:=0;
GenericCPU.L1ICache:=0;
GenericCPU.L2Cache:=0;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -