Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!cornell!uw-beaver!microsoft!danno From: danno@microsoft.UUCP (Daniel A. Norton) Newsgroups: comp.sys.ibm.pc Subject: Re: How to tell the difference between 80386 virtual 8086 mode and 286 real mode? Summary: Use SMSW Message-ID: <1657@microsoft.UUCP> Date: 29 Jul 88 16:54:19 GMT References: <1873@looking.UUCP> Organization: Microsoft Corp. Lines: 30 In article <1873@looking.UUCP>, brad@looking.UUCP (Brad Templeton) writes: > Does anybody have any info on this? Please respond by mail. > I know you can spot a 386 in real mode by trying to set the IOPL bits in > the flag word, but this doesn't work in virtual 8086 mode. I sent you mail on this, but I've since been told of a better method. The best way is to use the SMSW instruction. It is non-privileged (as opposed to LMSW) so it works fine in Virtual 8086 mode. This instruction stores some flags into a 16-bit operand. The low bit indicates whether or not the system is in protect mode. A 286 in real-mode has a zero in this bit. An 80386 in V86 mode (presumably also in protect mode) has a one in this bit. I'm not sure that it makes sense to have the V86 mode set while in real-mode, so this should be safe. Example: SMSW AX RCR AX,1 JC V86Mode R286Mode: . . . V86Mode: This presumes, of course, that you know that you're not executing on an 8088, because SMSW is illegal on that chip. -- Any opinions expressed are mine, not my employer's. nortond@microsof.beaver.washington.EDU nortond%microsof@uw-beaver.ARPA {decvax,decwrl,sco,sun,trsvax,uunet,uw-beaver}!microsof!nortond