check if in real mode or PM

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
packet50071
Member
Member
Posts: 43
Joined: Sat Dec 22, 2007 2:27 pm
Location: canada

check if in real mode or PM

Post by packet50071 »

Is there A way check ??
Technology is here to make things easier not harder.
User avatar
ucosty
Member
Member
Posts: 271
Joined: Tue Aug 08, 2006 7:43 am
Location: Sydney, Australia

Post by ucosty »

the eflags register, i think, has a flag for protected mode.
The cake is a lie | rackbits.com
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post 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?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Post 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
~ Lukem95 [ Cake ]
Release: 0.08b
Image
User avatar
XCHG
Member
Member
Posts: 416
Joined: Sat Nov 25, 2006 3:55 am
Location: Wisconsin
Contact:

Post 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.
On the field with sword and shield amidst the din of dying of men's wails. War is waged and the battle will rage until only the righteous prevails.
User avatar
packet50071
Member
Member
Posts: 43
Joined: Sat Dec 22, 2007 2:27 pm
Location: canada

Post 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
Technology is here to make things easier not harder.
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Post 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.
~ Lukem95 [ Cake ]
Release: 0.08b
Image
User avatar
ucosty
Member
Member
Posts: 271
Joined: Tue Aug 08, 2006 7:43 am
Location: Sydney, Australia

Post 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.
The cake is a lie | rackbits.com
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

Look up what the instruction SMSW does:
http://faydoc.tripod.com/cpu/smsw.htm

You can load ax and test bit 1
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Post 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.
~ Lukem95 [ Cake ]
Release: 0.08b
Image
User avatar
packet50071
Member
Member
Posts: 43
Joined: Sat Dec 22, 2007 2:27 pm
Location: canada

Post 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 !
Technology is here to make things easier not harder.
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post 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.
User avatar
packet50071
Member
Member
Posts: 43
Joined: Sat Dec 22, 2007 2:27 pm
Location: canada

Post by packet50071 »

yeah -- I was just making sure i got ur point :)
thx everyone
Technology is here to make things easier not harder.
Post Reply