home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / insidetp / 1990_10 / cpu.pas < prev    next >
Pascal/Delphi Source File  |  1990-10-01  |  2KB  |  61 lines

  1. PROGRAM Cpu;
  2.  
  3. TYPE
  4.   SysInfo = OBJECT
  5.     FUNCTION GetCpuId: Integer;
  6.     END;
  7.  
  8. {$F+}FUNCTION SysInfo.GetCpuId: Integer;{$F-}
  9.  
  10. BEGIN
  11.  
  12. INLINE(          {Inline assembler code to identify the CPU TYPE}
  13.  
  14.  $9C/             {  pushf           ;save Flags register       }
  15.  $5B/             {  pop   bx        ;Store Flags in BX         }
  16.  $81/$E3/$FF/$0F/ {  and   bx,$0fff  ;clear bits 12-15          }
  17.  $53/             {  push  bx        ;restore to stack          }
  18.  $9D/             {  popf            ;pop word into Flags reg   }
  19.  $9C/             {  pushf           ;store Flags on stack      }
  20.  $58/             {  pop   ax        ;recover Flags word        }
  21.  $25/$00/$F0/     {  and   ax,$0f000 ;if bits 12-15 are set,    }
  22.  $3D/$00/$F0/     {  cmp   ax,$0f000 ; the proc. is an 8086     }
  23.  $74/$19/         {  jz    is8086                               }
  24.  $81/$CB/$00/$F0/ {  or    bx,$0f000 ;try to set 12-15 bits     }
  25.  $53/             {  push  bx        ;store on stack            }
  26.  $9D/             {  popf            ;pop word into the Flags   }
  27.  $9C/             {  pushf           ;store Flags on stack      }
  28.  $58/             {  pop   ax        ;recover Flags word        }
  29.  $25/$00/$F0/     {  and   ax,$0f000 ;if bits 12-15 cleared     }
  30.  $74/$06/         {  jz    is80286   ;  the proc. is an 80286   }
  31.                   {is80386:                                     }
  32.  $B8/$82/$01/     {  mov   ax,386    ;else proc. is a 386 CPU   }
  33.  $E9/$09/$00/     {  jmp   done      ;set as a 386 CPU          }
  34.                   {is80286:                                     }
  35.  $B8/$1E/$01/     {  mov   ax,286    ;set the 80286 indicator   }
  36.  $E9/$03/$00/     {  jmp   done                                 }
  37.                   {is8086:                                      }
  38.  $B8/$56/$00/     {  mov   ax,86     ;set the 8086 indicator    }
  39.                   {done:                                        }
  40.  $89/$EC/         {  mov   sp,bp     ;restore sp                }
  41.  $5D/             {  pop   bp        ;restore bp                }
  42.  $CA/$04/$00);    {  retf  4         ;pop ptr to self           }
  43.  
  44.  END;
  45.  
  46. VAR
  47.   CpuNbr  : Integer;
  48.   SI : SysInfo;
  49.  
  50. BEGIN
  51.   WriteLn('CPU Identification Routine');
  52.   CpuNbr := SI.GetCpuId;
  53.   Write('You are using a ');
  54.   CASE CpuNbr OF
  55.      86 : Write('8086');
  56.     286 : Write('80286');
  57.     386 : Write('80386');
  58.     END;
  59.   WriteLn(' Cpu');
  60.   END.
  61.