Path: utzoo!attcan!uunet!aplcen!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!uwm.edu!bionet!agate!shelby!portia.stanford.edu!dhinds From: dhinds@portia.Stanford.EDU (David Hinds) Newsgroups: comp.os.msdos.programmer Subject: Re: Detecting an 80486 Message-ID: <1990Jul22.185546.136@portia.Stanford.EDU> Date: 22 Jul 90 18:55:46 GMT References: <26a858b9@ralf> Organization: AIR, Stanford University Lines: 23 In article <26a858b9@ralf> Ralf.Brown@B.GP.CS.CMU.EDU writes: >In article <1990Jul20.230335.22816@ddsw1.MCS.COM>, andyross@ddsw1.MCS.COM (Andrew Rossmann) wrote: >} For the 286, it tries the SMSW DX instruction (whatever that does.) >} The code come from a program by Robert Collins, and I just made a few >}changes to fit INFOPLUS (and fix the 386 problem!) > >Unfortunately, your program will fail miserably on my system (and about a >million others), because I am running QEMM-386. QEMM runs in protected mode >with DOS in virtual-86 mode. Any invalid opcode exception that your >program generated invokes the QEMM exception handler, NOT YOURS. And the >QEMM exception handler gives the choice of terminating or rebooting. I >expect similar behavior from 386^Max, CEMM, AllCharge386, MICEMM, .... The SMSW instruction will fail if executed on less than a 286, so it is a safe test even in the presence of QEMM. As a bonus, the low-order bit of the MSW (machine status word) is the protected-mode flag. The only way it can be set under DOS is if a 386 is running in virtual-86 mode. So, if the bit is set, you are on a 386. If it isn't, you are either on a 286 or 386 in real mode, and it is safe to try a 386 instruction and trap the interrupt. -David Hinds dhinds@popserver.stanford.edu