Page 1 of 1

16-bit protected mode

Posted: Sat Mar 08, 2008 8:26 am
by Love4Boobies
Can anyone please tell me what exactly this 16-bit protected mode is? Please don't answer with something like "that sounds pointless" because I'm only asking out of curiosity... Intel docs don't say anything about this and I'm not even sure if it's something that 80286 CPUs had instead of the current 32-bit protected mode or a mode modern CPUs could still use (which would make sense, bause of compatibility issues). Any knowledge about this?

Posted: Sat Mar 08, 2008 8:44 am
by lukem95
It's called unreal mode.

Its where your in PMODE, but the A20 gate has been enabled, so you have access to all 4gigs of memory space.

i think there should be a wiki article on it.

Posted: Sat Mar 08, 2008 9:54 am
by inflater
Well unreal mode is a switch to 32bit protected mode and back (once) using a special GDT. Thus, real mode no longer has the 64K segment limit. 16-bit protected mode is 16-bit protected mode, it's not unreal mode. In 16-bit protected mode you can address max. 16 MB of RAM (correct me if i'm wrong). For example Windows 2.0/286, Windows 3.0 and Windows 3.1 could run in 16-bit protected mode or real mode. And yes, pmode was in 80286 too, but slightly different from the 386 one. ;)

I can post you some example asm code in TASM for setting the 16bit pmode back and forth (there wasn't a method how to switch back to real mode on 80286. That's why games for 80286 weren't in pmode [but it wasn't a big deal, since 80286's had ~1 MB RAM installed] - but later, the function how to exit pmode has been "exploited" by Windows.)

Posted: Sat Mar 08, 2008 7:41 pm
by pcmattman
Unreal mode simply uses the CPU descriptor caches to allow access to the full 4 GB of RAM by entering PMode, loading a GDT, and setting descriptors so that the caches are updated.

16-bit protected mode is PMode with 16-bit instructions (correct me if I'm wrong).

Posted: Sun Mar 09, 2008 4:34 pm
by Combuster
short answer:
pcmattman wrote:16-bit protected mode is PMode with 16-bit instructions (correct me if I'm wrong).
long answer:
The 286 was the first CPU to feature protected mode - you could put it in that mode, and have process isolation based on segmentation. Since the 286 didn't feature 32-bit registers, the only option was to use 16-bit code and registers. A new register was added, the machine status word, which held the bit to enter protected mode.

in the 386, all registers became 32-bit. They renamed the 32-bit version of the machine status word to cr0. Then they added paging and 32-bit code and new addressing modes on top of the 16-bit versions present.

The current intel manuals are pretty vague about what protected-mode features were present on the 286, and which ones were added on the 386 and later, so I don't have the details on the modifications made to the GDT and IDT to allow for this upgrade. Most likely, parts of the GDT are ignored since IIRC the 286 only had a 24-bit address bus (16MB), while the 386 featured the full 32 bits (4GB)

But yes, 286 protected mode code should still work. The consensus however is to stay away from that infant version of protected mode and either require a 386 or use real or unreal mode (which is a completely different thing, note that unreal mode doesn't exist on a 286 as well)