Computing.Net > Forums > Programming > switch from real to protected mode

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

switch from real to protected mode

Reply to Message Icon

Name: xyoavx
Date: November 20, 2004 at 08:33:31 Pacific
OS: windows 98 SE
CPU/Ram: pentium 4.0
Comment:

Hello,
I try to write my oun OS and would like to ask:
When booting, immediately after entering from real to the protected mode ( by enabling the PE bit in CR0), the value of the cs register iz zero.It means that from this moment, being in protected mode, the processor uses the null selector, when computing the address of the current instruction. This crashes the system. How can I solve this problem ?
Thanks in advance.
xyoavx



Sponsored Link
Ads by Google

Response Number 1
Name: Birdman
Date: November 22, 2004 at 05:32:15 Pacific
Reply:

Actually, switching to protected mode won't do anything with CS. What you need to do is switch to the new mode, then do a long jump in the code. You can do this by either pushing the new segment selector and offset onto the stack and doing a retf, or by just doing a jmp 0x??:0x?? with the new selector and offset.

The values in selectors aren't actually ACCESSED per se until they are used. The switch to protected mode will check that there is a valid value in the register (ie 0,0x8,0x10...), but for other reasons 0 must be the null selector and is not used, so you need to do a long jump in the code to "wake up" CS to where you are.

Hope that helps!


0

Response Number 2
Name: xyoavx
Date: November 22, 2004 at 23:36:07 Pacific
Reply:

Hello Birdman
Thank you very much for your answer.From your email,I understand that immediately after enabling the PE bit in CR0,CS is not yet used as a selector.When performing the jump,CS is used in its "regular" way.CS will be used as a selector only after the jump.So,my question is:how the processor "knows" when it should begin to use the CS as a selector ?
If the jump will not be done,will the processor continue to use CS like in real mode ?
Thanks in advance
xyoavx


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: switch from real to protected mode

protected mode/real mode question www.computing.net/answers/programming/protected-modereal-mode-question/2375.html

Protected Mode And 32-bit Real Mode www.computing.net/answers/programming/protected-mode-and-32bit-real-mode/10917.html

Real mode int's in protected mode? www.computing.net/answers/programming/real-mode-ints-in-protected-mode/10875.html