Bona Fide OS Development
http://forums.osdever.net/

how to know if i'm in proteced or in real mode
http://forums.osdever.net/viewtopic.php?f=6&t=210
Page 1 of 1

Author:  likesogunfire [ Sat Mar 06, 2010 8:34 am ]
Post subject:  how to know if i'm in proteced or in real mode

I wanted to ask how to know (with what kind of code) if right now my bootloader has loaded in real mode or protected mode? For example, I want to print out A, if I'm already in proteced mode. Can anyone give me a code example or maybe theres another method with whom I can get the desired effect.

Author:  Kieran [ Sat Mar 06, 2010 10:02 am ]
Post subject:  Re: how to know if i'm in proteced or in real mode

I wont give code, but using ASM or C, you can check for the relevant 1 Bit flag in CR0.

Author:  XanClic [ Sun Mar 07, 2010 4:23 pm ]
Post subject:  Re: how to know if i'm in proteced or in real mode

But you must make sure that the code is the same both in 16 and 32 bit mode. ;)

Author:  Sharpner [ Sat Mar 13, 2010 6:56 am ]
Post subject:  Re: how to know if i'm in proteced or in real mode

isn't it simply

cr0 % 2 == 0 => real mode else protected mode?

or am I wrong here? :D

Page 1 of 1 All times are UTC - 6 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/