Page 1 of 1

check if in real mode or PM

Posted: Wed Dec 26, 2007 12:56 pm
by packet50071
Is there A way check ??

Posted: Wed Dec 26, 2007 12:58 pm
by ucosty
the eflags register, i think, has a flag for protected mode.

Posted: Wed Dec 26, 2007 1:07 pm
by Combuster
You should check CR0.PM. If its set you're in protected mode or v8086 mode, else you are in real mode.

Any reason why you even need to check?

Posted: Wed Dec 26, 2007 3:11 pm
by lukem95
Thats what i was thinking, why would you ever need to check (or indeed not know)?

I'm sure the Intel manuals will have more info

Posted: Wed Dec 26, 2007 5:12 pm
by XCHG
Combuster has already answered your question. However, other ways could be for example to use an instruction that is only valid in the protected mode. I haven't tried this method but it should work.

Posted: Wed Dec 26, 2007 5:20 pm
by packet50071
thx - My first question was does GRUB give control to me after going in to PM or not ! -- so i needed to figure out my self but i couldn't -- so i am here :D

Sorry for my ignorance but i cannot find a manual in intel's site for Pentium 4 processor -- it only shows software devloper's manual for
Intel® 64 and IA-32 Architectures Software Developer's Manuals :'(

http://www.intel.com/design/Pentium4/documentation.htm

Posted: Wed Dec 26, 2007 5:34 pm
by lukem95
pentium 4 is still very new (as processors go) and therefore it wouldnt be very backward compatable... also most emulators use older models.

Posted: Wed Dec 26, 2007 5:36 pm
by ucosty
lukem_95 wrote:pentium 4 is still very new (as processors go) and therefore it wouldnt be very backward compatable... also most emulators use older models.
... ?

Pentium 4's use the same IA-32 architecture as every other intel 32-bit chip. They are all compatible with each other.

Posted: Wed Dec 26, 2007 8:30 pm
by Dex
Look up what the instruction SMSW does:
http://faydoc.tripod.com/cpu/smsw.htm

You can load ax and test bit 1

Posted: Thu Dec 27, 2007 4:32 am
by lukem95
yeah, but surely there are new instructions or quirks that wont work?

maybe im being stupid, i made several pretty ridiculous posts last night =\ too much christmas merryness i fear.

Posted: Fri Dec 28, 2007 10:38 am
by packet50071
this was my code

Code: Select all

  SMSW AX
  test AX ,1
  jnz  _printsomething
and it did print - so it means that its in PM right !

Posted: Fri Dec 28, 2007 2:33 pm
by Dex
packet50071 wrote:this was my code

Code: Select all

  SMSW AX
  test AX ,1
  jnz  _printsomething
and it did print - so it means that its in PM right !
Which i pointed out in my post, but i have been told off for just dumping code, so i use perdo code.

Posted: Fri Dec 28, 2007 3:00 pm
by packet50071
yeah -- I was just making sure i got ur point :)
thx everyone