home *** CD-ROM | disk | FTP | other *** search
/ Frostbyte's 1980s DOS Shareware Collection / floppyshareware.zip / floppyshareware / APOG / ASM2.ZIP / CPUIDLC.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-02-16  |  1.3 KB  |  37 lines

  1.  
  2. ;*----------------------------------------------------------------
  3. ;*   from larry caldwell
  4. ;*----------------------------------------------------------------
  5. ;  This is the code for CPU autodetection.
  6. ;  I picked it off of the Power
  7. ;  Programming conference on PC-MAGNET.
  8. ;  The guy who posted it didn't write it,
  9. ;  and didn't know where it came from.
  10. ;  Probably INTEL, because it doesn't deal with NEC processors.
  11.  
  12.         CLI                     ; runs in real mode only!
  13.         PUSHF                   ; save machine flags
  14.         MOV    AX,0             ; set all flag bits to zero
  15.         PUSH   AX
  16.         POPF
  17.         PUSHF                   ; retrieve flag bits
  18.         POP    AX
  19.         TEST   AH,080H
  20.         JNZ    xxxx             ; bit set if CPU 8088
  21.         ;
  22. ; determine if CPU 286 or 386
  23.         MOV    AX,07000H        ; set bits 14, 13, 12 - nested task/iopl bits
  24.         PUSH   AX               ; put bits into flag register
  25.         POPF                    ; via stack
  26.         PUSHF                   ; get bits back
  27.         POP    AX
  28.         TEST   AX,07000H        ; are any bits still set?
  29.         JZ     yyyy             ; no bits set CPU 80286
  30.         JNZ    zzzz             ; bits set CPU 80386
  31.  xxxx:
  32.  yyyy:
  33.  zzzz:
  34.         POPF
  35.         STI
  36.  
  37.