• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 186
  • Last Modified:

How do I identify which CPU i have from a TP7 program?

I need how to identify what kind of processor and speed has a pc, could tell me some one how to do it?
0
baguirre
Asked:
baguirre
1 Solution
 
HypoCommented:
K, In normal pascal you can use "Test8086" to check if the processor is 8086, 80286 or 80386... But it won't give show you if your cpu is better than an 80386 cpu. therefore you need to check wich cpu > 80386 that you have... And you have to use asssembler for that one.

Anyway, all you have to test is if the CPU is 80386, 80486 or pentium. Since every CPU since the Pentium has an instruction called CPUID, from wich you could easily Identify it with. I suggest that you get some documents on the CPUID instruction since It can be used in more than one way.

Anyway, here's a pice of codde I found on my HDrive, (It's not made by me) I've only altered it a bit. I hope this helps you enough...

{
   0 = 8086
   1 = 80186/80286
   2 = 80386
   3 = 80386   (new)
   4 = 80486   (new)
   5 = Pentium (new)
   6 = ??

Note that for Pentium and higher CPUs, the new CPUID instruction is used to
retrieve the processor family number.  This code should work on post-Pentium
(80686-class) CPUs and Pentium compatibles, and could return numbers > 5.
}
program CPUTest;

const iDStr : string[13] = '            ';

 begin
  if (Test8086 = 2) then         { RTL check stops at 2 = 386}
  asm
             INC    Test8086     { 3 = 386, for consistency }
                                 { Do we have a 386 or a 486? }
                                 { Does pushf/popf preserve the Alignment Check bit? (386=no, 486=yes) }
             MOV    BX, SP       { save current stack pointer }
             AND    SP, NOT 3    { align stack to avoid AC fault }
    DB $66;  PUSHF
    DB $66;  POP    AX
    DB $66;  MOV    CX, AX
    DB $66,$35; DD $40000        { xor AC bit in EFLAGS }
    DB $66;  PUSH   AX
    DB $66;  POPF
    DB $66;  PUSHF
    DB $66;  POP    AX
    DB $66;  XOR    AX, CX       { Is AC bit toggled? }
             JE @@1              { if not, we have a 386 }
             AND    SP, NOT 3    { align stack to avoid AC fault }
    DB $66;  PUSH   CX
    DB $66;  POPF                { restore original AC bit }
             MOV    SP, BX       { restore original stack pointer }
             MOV  Test8086, 4    { we know we have at least a 486 }

    { Do we have a 486 or a Pentium? }
    { Does pushf/popf preserve the CPUID bit? (486=no, P5=yes) }
    DB $66;  MOV    AX, CX       { get original EFLAGS}
    DB $66,$35; DD $200000      { XOR id bit in flags}
    DB $66;  PUSH   AX
    DB $66;  POPF
    DB $66;  PUSHF
    DB $66;  POP    AX
    DB $66;  XOR    AX, CX      { Is CPUID bit toggled? }
             JE @@1             { if not, we have a 486 }
    DB $66;  XOR    AX, AX
    DB $0F,$A2                  { CPUID, AX = 0 (get CPUID caps) }
             LEA DI,IDStr
    DB $66;  MOV [DI+1],BX
    DB $66;  MOV [DI+5],DX
    DB $66;  MOV [DI+9],CX
    DB $66;  CMP    AX, 1
             JL @@1             { if < 1, then exit }
    DB $66;  XOR    AX, AX
    DB $66;  INC    AX
    DB $0F,$A2                  { CPUID, AX = 1 (get CPU info)   }
             AND    AX, $0F00   { mask out all but family id }
             SHR    AX, 8
             MOV    Test8086, al      { Pentium family = 5 }
   @@1:
  end;
  writeln('Test8086: ',Test8086);
  writeln(IDStr);
 end.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now