Yes, that's how it works on all x86 processors when in protected mode. A code segment descriptor is an entry in the GDT whose bits 43 and 44 are set to 1. Bit 0 and 1 of a segment selector determine the protection level to use, which must be at least as high as the DPL of the segment descriptor (bits 45 and 46). Bit 2 of a selector, when set to 1, indicates that the segment descriptor is to be taken from the current LDT instead of the GDT. So, a selector of 8 would refer to the descriptor at GDT offset 8 with a protection level of 0, and a selector of 1fh would refer to the descriptor at LDT offset 18h with a protection level of 3.How did you know that? why the upper 13bits in the cs register are an index into a code segment descriptor? Is all x86 computers made like this? And by code segment descriptor you mean apart of an entry in the GDT table (limit and base)
The 66h and 67h prefixes only affect the following instruction. A call or jmp instruction prefixed with 66h indicates a 32-bit destination address, but the called code still runs in 16 bit mode.Could I call a 32 bit program if I manual put a 66 or 67 prefix on it.
Instead of going into protected mode?
No, to go into the so-called unreal mode, you first have to go to protected mode, because that's how you load the segment registers with different limits and default operand sizes. At startup, the LDTR is set to 0, but still marked as present with a base address of 0 and limit of 0ffffh. The GDTR also has a base of 0h and a limit of 0ffffh. However, you should not rely on the initial value of LDTR and GDTR, since the BIOS uses them during booting. If you don't change GDTR, it will likely point to a GDT in ROM which often begins with 32-bit code and data segment descriptors with base 0 and limit 0ffffffffh, but this can change between BIOSes. If you don't do a far jump and do not change the segment registers, nothing will happen and you will still run in 16 bit mode with the same segments as before.If I didn't want to go into protected mode can I just go into unreal mode without going first into protected mode?
What would happen if I set the cr0 bit to protected mode but I never setup the GDT stuff or did a far jump just curious?
Where is the default gdtr , ldtr ,...etc pointing before setting them up curious?
I am thinking the ldtr is pointing to the IVT at 0x00000000 ... though I am not 100% sure.
If you run in 32 bit unreal mode, interrupts must be disabled or handled by your own code, and EIP must be below 10000h at all times while interrupts are enabled.
Unreal mode isn't a mode, it's just real mode with segment descriptors having been loaded in protected mode. Long mode is a form of protected mode. When in protected mode (and not in long mode), you can go to virtual 8086 mode by executing an IRET instruction with bit 17 of the EFlags on the stack set. In this mode, segments work like in real mode, but interrupts and exceptions cause the processor to exit virtual 8086 mode unless redirected to the virtual 8086 mode program using the interrupt redirection bitmap in the TSS. Segments are fixed with limits of 0ffffh, protection level of 3, and operand size of 16 bits, and the IVT is fixed at 0.Being on a 32bit arch x86 machine is their any other modes other then real mode , unreal mode , and protected mode? ( I know when we go to 64bits they have one more called long mode)
Another words is their any different mode or corosponding bits for modes that I haven't commented on?
No, you can use the IVT just like before. However, if the default operand size has been set to 32 bits, the interrupt handlers must also consist of 32 bit code.Is their any other difference in unreal mode from real mode apart from the fact you can access all 4GB of memory in unreal as opposed to real?
Can you still use the IVT of real mode in unreal mode ,...etc ?