home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l044 / 4.ddi / DEMOS.ZIP / TEST286.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1990-10-23  |  1.0 KB  |  42 lines

  1.  
  2. { Copyright (c) 1990 by Borland International, Inc. }
  3.  
  4. (*
  5.   Programs compiled with {$G} compiler directive enabled do not
  6.   check the processor at runtime to determine whether it is
  7.   286-compatible. Trying to execute 80286 instructions on an 8086
  8.   or an 8088 will lock up the computer. This program shows how to
  9.   check for the presence of a 286-compatible chip at runtime.
  10.  
  11.   If you want to put code like this in a program with {$G+}
  12.   enabled, put the test and halt code in the initialization
  13.   section of the first unit in the main program's USES clause.
  14. *)
  15.  
  16. program Test286;
  17.  
  18. function Is286Able: Boolean; assembler;
  19. asm
  20.         PUSHF
  21.         POP     BX
  22.         AND     BX,0FFFH
  23.         PUSH    BX
  24.         POPF
  25.         PUSHF
  26.         POP     BX
  27.         AND     BX,0F000H
  28.         CMP     BX,0F000H
  29.         MOV     AX,0
  30.         JZ      @@1
  31.         MOV     AX,1
  32. @@1:
  33. end;
  34.  
  35. begin
  36.   if not Is286Able then
  37.   begin
  38.     Writeln('Need an 80286-compatible system to run this program');
  39.     Halt(1);
  40.    end;
  41. end.
  42.