Hello,
Whats the diff. between the RMode & the PMode and what can i do in PMode and not in the other one ?
RMode & PMode
Re:RMode & PMode
That question is almost impossible to answer accurately on a web forum like this!
Obtain the Pentium manuals from http://developer.intel.com/. Read them.
Obtain the Pentium manuals from http://developer.intel.com/. Read them.
Re:RMode & PMode
To answer this quickly (if that?s even possible!), I will give you a short overview?
When you switch the CPU into protected mode, it will allow you to directly access all of your computers available memory and even enable the use of virtual memory (via paging).
Almost everything you couldn?t do in ?real-mode? you can do with protected mode enabled.
You can define segments to be any size you want (1 byte to 4GB!). You can have a few segments, like a data/stack and code segment, or you can have as many segments of any kind you want up to 8192 of them!
The 80386 makes multitasking a very easy job to implement into your software since most the hardware inside the 80386 does the work for you (if you want it to).
Most hardware on your computer doesn?t have to be accessed through these small memory windows or holes like they did in the 8086 real-mode. Most video display routines can be wrote to access every pixel at any time without bank switching, even with high resolutions.
Once you get very advanced with protected mode programming, you will learn how to ?protect? segments from interfering with other segments. This is almost needed for multitasking operating systems. This is where the name ?protected-mode? comes from. To switch the CPU into a protected state so that it is almost crash proof if programmed correctly (Linux is a good example).
32-Bit code can be generated to run at its native speed and size while in 80386 protected mode. You can use 32-bit code while in real-mode as long as you have an 32-bit CPU (and I?m sure you do), however, it won?t run as fast and each instruction will take up one extra byte to tell the 16-bit mode that a 32-bit instruction is coming next.
Generally speaking, everything will run (execute) faster in p-mode since it is the CPU native environment.
Normally in real-mode every address:offset is ?fixed? at a specific location always. In p-mode this doesn?t even have to be true if paging is enabled. Paging allows addresses to be translated so that each piece of code can start at 0h if you would like. This allows you to make the environment in p-mode feel almost virtual. This is how older versions of Windows allowed many DOS consoles to be opened and running, because each one thought they were the only program running, and they started at physical memory 0, even though they actually didn?t because the addresses were generated virtually through paging. This is more complex than it sounds though and don?t expect to learn much about it unless you have 2 years of p-mode knowledge behind you.
Normally when switching to p-mode, all those interrupts you used to have, like DOS interrupt 21h are all gone and can no longer be used. Even to display a string on the screen requires you to write your own software routines to do so. This is why most old time DOS users convert to using so called ?DOS extenders?. These libraries/executables/whatever allows you to program for 32-bit protected mode and still use a DOS like underlying system. This new underlying system relies souly on the extender since real DOS no longer is of use in a 32-bit environment!
Believe it or not, this is the ?quick? overview of some things you can do that differs from 16-bit real mode. ;D
When you switch the CPU into protected mode, it will allow you to directly access all of your computers available memory and even enable the use of virtual memory (via paging).
Almost everything you couldn?t do in ?real-mode? you can do with protected mode enabled.
You can define segments to be any size you want (1 byte to 4GB!). You can have a few segments, like a data/stack and code segment, or you can have as many segments of any kind you want up to 8192 of them!
The 80386 makes multitasking a very easy job to implement into your software since most the hardware inside the 80386 does the work for you (if you want it to).
Most hardware on your computer doesn?t have to be accessed through these small memory windows or holes like they did in the 8086 real-mode. Most video display routines can be wrote to access every pixel at any time without bank switching, even with high resolutions.
Once you get very advanced with protected mode programming, you will learn how to ?protect? segments from interfering with other segments. This is almost needed for multitasking operating systems. This is where the name ?protected-mode? comes from. To switch the CPU into a protected state so that it is almost crash proof if programmed correctly (Linux is a good example).
32-Bit code can be generated to run at its native speed and size while in 80386 protected mode. You can use 32-bit code while in real-mode as long as you have an 32-bit CPU (and I?m sure you do), however, it won?t run as fast and each instruction will take up one extra byte to tell the 16-bit mode that a 32-bit instruction is coming next.
Generally speaking, everything will run (execute) faster in p-mode since it is the CPU native environment.
Normally in real-mode every address:offset is ?fixed? at a specific location always. In p-mode this doesn?t even have to be true if paging is enabled. Paging allows addresses to be translated so that each piece of code can start at 0h if you would like. This allows you to make the environment in p-mode feel almost virtual. This is how older versions of Windows allowed many DOS consoles to be opened and running, because each one thought they were the only program running, and they started at physical memory 0, even though they actually didn?t because the addresses were generated virtually through paging. This is more complex than it sounds though and don?t expect to learn much about it unless you have 2 years of p-mode knowledge behind you.
Normally when switching to p-mode, all those interrupts you used to have, like DOS interrupt 21h are all gone and can no longer be used. Even to display a string on the screen requires you to write your own software routines to do so. This is why most old time DOS users convert to using so called ?DOS extenders?. These libraries/executables/whatever allows you to program for 32-bit protected mode and still use a DOS like underlying system. This new underlying system relies souly on the extender since real DOS no longer is of use in a 32-bit environment!
Believe it or not, this is the ?quick? overview of some things you can do that differs from 16-bit real mode. ;D
Re:RMode & PMode
AFAIK that's simply not true. Thanks to having to go through two different translation phases (Segmentation+paging) for memory access protected mode is actually slower than real mode in practically every case. However the benefits of protected mode far outweigh the minor overhead involved in using it.darklife wrote: Generally speaking, everything will run (execute) faster in p-mode since it is the CPU native environment.
Re:RMode & PMode
People have been running protected mode operating systems on the x86 for maybe 15 years. Do you not think that Intel etc. optimise their chips for 32-bit protected mode at the expense of 16-bit real mode? It is said (I don't have any proof) that 32-bit code is faster than 16-bit code because current CPUs are better at running 32-bit code.
Re:RMode & PMode
Guess the only way to find out would be to write some 16/32-bit test code (Same algorithm/instruction size) and throw it at a modern processor. Could be it's a bit like the hardware task switch where nobody actually uses it so further optimisation is low on the agenda. Happy to take Tim's word for it right now though, he's looked at a heck of a lot more x86 papers than I have .