home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / PCTV3N3.ZIP / CPU.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-04-01  |  1.1 KB  |  49 lines

  1. function CPUtype:word;
  2.  
  3. (* Returns a value depending on the CPU type
  4.       0 if 8088/V20 or compatible
  5.       1 if 80286
  6.       2 if 80386 or better
  7.  
  8.     Original code based on Nicholas Wilt's code in
  9.     PC Techniques Feb/Mar '91 issue.  *)
  10.  
  11. label
  12.   quit;
  13.  
  14. begin
  15.   asm
  16.     xor dx,dx      { clear dx }
  17.     push dx
  18.     popf           { Clear flags }
  19.     pushf
  20.     pop ax         { load 'cleared' flags into AX }
  21.     and ax,0f000h    { check high bits of ax for F0 }
  22.     cmp ax,0f000h
  23.     je quit        { quit if 8088 }
  24.     inc dx
  25. (*
  26.     push 0f000h    I removed this statement because
  27.                    it won't assemble in non-286 mode!
  28. *)
  29.     mov ax,0f000h  { Now check for 80286 }
  30.     push ax
  31.     popf
  32.     pushf
  33.     pop ax
  34.     and ax,0f000h { If the top 4 bits aren't set then }
  35.     jz quit       { it's a 286 }
  36.     inc dx        { else it's a 386 or better }
  37. quit:
  38.     mov @result,dx  { move CPU type into function return }
  39.   end;
  40.  end;
  41.  
  42. begin
  43.   write('The CPU is a ');
  44.   case CpuType of
  45.     0:writeln('8088/8086/V20');
  46.     1:writeln('80286');
  47.     2:writeln('80386/80486');
  48.   end;
  49. end.