Real Mode is 16-Bit mode.
Protected Mode is 32-Bit mode.
OK! Then why the code to enter pmode is this:
Code: Select all
mov eax, cr0
or al, 1
mov cr0, eax
Code: Select all
mov eax, cr0
or al, 1
mov cr0, eax
There is nothing particularly 16 bit-ish about real mode. It is just that MS-DOS was a 16 bit operating system, and the early 16 bit processors from Intel ran exclusively real mode.INF1n1t wrote:There is something, I really can't understand:
Real Mode is 16-Bit mode.
Protected Mode is 32-Bit mode.
OK! Then why the code to enter pmode is this:
When we are in real mode, which is 16 bit mode...I don't get it!Code: Select all
mov eax, cr0 or al, 1 mov cr0, eax
Yes, 16-bit rmode just means the default operation is 16-bits, you can do 32-bit operations, but each instruction will have a 0x66 prefix added to it to denote that it is a 32-bit instruction while in 16-bit mode. All 3 of those instructions assume 16-bit mode, but the next instruction after the mov cr0, eax will assume 32-bit mode, so it will not have the prefix affixed to it, you inform your assembler this by using the [bits 32] command. Also, pmode is not 32-bit by itself, there is 16-bit pmode and 32-bit pmode, and similarly, it uses these prefixes and can still run 32-bit code, however program size grows much faster due to having the prefix attached to each opcode (making the code slightly slower and take up more memory).INF1n1t wrote:There is something, I really can't understand:
Real Mode is 16-Bit mode.
Protected Mode is 32-Bit mode.
OK! Then why the code to enter pmode is this:
When we are in real mode, which is 16 bit mode...I don't get it!Code: Select all
mov eax, cr0 or al, 1 mov cr0, eax
Not completely correct (It seems to be a common misunderstanding):Ready4Dis wrote:Yes, 16-bit rmode just means the default operation is 16-bits, you can do 32-bit operations, but each instruction will have a 0x66 prefix added to it to denote that it is a 32-bit instruction while in 16-bit mode. All 3 of those instructions assume 16-bit mode, but the next instruction after the mov cr0, eax will assume 32-bit mode, so it will not have the prefix affixed to it, you inform your assembler this by using the [bits 32] command. Also, pmode is not 32-bit by itself, there is 16-bit pmode and 32-bit pmode, and similarly, it uses these prefixes and can still run 32-bit code, however program size grows much faster due to having the prefix attached to each opcode (making the code slightly slower and take up more memory).
The point of the far jumpis surely to reload the cs register with something meaningful in protected mode. If you carried on with the PE flag set, and with a paragraph address (rather than an index into the GDT) in cs, the system would crash.Combuster wrote:Not completely correct (It seems to be a common misunderstanding):Ready4Dis wrote:Yes, 16-bit rmode just means the default operation is 16-bits, you can do 32-bit operations, but each instruction will have a 0x66 prefix added to it to denote that it is a 32-bit instruction while in 16-bit mode. All 3 of those instructions assume 16-bit mode, but the next instruction after the mov cr0, eax will assume 32-bit mode, so it will not have the prefix affixed to it, you inform your assembler this by using the [bits 32] command. Also, pmode is not 32-bit by itself, there is 16-bit pmode and 32-bit pmode, and similarly, it uses these prefixes and can still run 32-bit code, however program size grows much faster due to having the prefix attached to each opcode (making the code slightly slower and take up more memory).
Changing the PE bit in CR0 differentiates between real mode and protected mode. The move doesn't force the processor into 32-bit mode, but leaves it where it was. So, when you enable PE, you'll be in 16 bit protected mode. To enter 32-bit protected mode, you'll have to reload CS (the far jump).
Oh, the magic of Unreal Mode.mathematician wrote:The point of the far jumpis surely to reload the cs register with something meaningful in protected mode. If you carried on with the PE flag set, and with a paragraph address (rather than an index into the GDT) in cs, the system would crash.
There's also other CPU modes...INF1n1t wrote:I think that clears it up. I thought that the Protected Mode is a 32-bit mode, but now I now the truth
Code: Select all
jmp dword 0x8:00100000