• Please review our updated Terms and Rules here

Are win16 applications real mode or protected mode or both?

alank2

Veteran Member
Joined
Aug 3, 2016
Messages
2,256
Location
USA
Are win16 applications real mode or protected mode or both?
 
Specifically, software for Windows 2.x and earlier was written to run in Real Mode, Windows 3.0 introduced “Standard”, IE, 286 protected mode. Some old software compiled for Real Mode can run in Standard mode, but subject to limits. (It can’t rely on segment arithmetic, there are memory allocation restrictions, etc.) You’ll get a warning trying to force old software to run in Standard mode and your mileage may vary, a lot.
 
A lot of the Win3.0 applications were able to run in both real mode and protected mode. Of course, there were a number of applications converted from Win 2.x that failed in both real and protected mode needing too many resources to run in real mode and not having every code path checked to fix protection faults. It is probably a good idea to avoid Windows applications released in 1990.
 
A number of the applets supplied with Windows 1.x give a protection fault at startup when run in protected mode, because (IIRC) their C runtime tries to access PSP:002Ch but the variable used for the PSP segment is initialised to 0. So they end up trying to read 0000:002C and get a protection error. It's not as if the runtime actually uses the value it reads, anyway, so NOPping it out is probably the way to go here.
 
Windows 2.0 came in 3 flavors, one was real mode only, one for 286 processors that ran in protected mode, and another of 386.

Windows 2 and 3 also had a conmand line option /r to start windows in real mode.

Note: this is all based on memory, so things could be wrong here…
 
Windows 1 and 2 were both real mode system. Windows 3 could run in either protected mode or real mode.
Windows 286 was Windows 2 with two minor 286 specific features bolted on: the usage of the HMA before DOS got ahold of that 64K region and an early version of XMS drivers so any Windows application could call XMS for additional memory. Windows 286 would still run on an 8088 machine but it would be slow.
Windows 386 ran Windows 2 in real mode in a single VDOS machine with a layer that coordinated between Windows VDM and the various DOS applications in their own VDMs.
Windows 3 enhanced mode was similar to Windows 386 except Windows was running in almost standard protected mode in a VDM with some extensions to handle virtual memory.
 
Windows 2.0 came in 3 flavors, one was real mode only, one for 286 processors that ran in protected mode, and another of 386.

Nope. I was typing a response similar to above but got beat to it, but yeah, short version is all the different flavors ran *Windows* software in Real Mode. (Or, technically, a vm86 instance for Windows/386.)
 
Windows 3 enhanced mode was similar to Windows 386 except Windows was running in almost standard protected mode in a VDM with some extensions to handle virtual memory.

FWIW, it’s my vague recollection that the 386’s programming model lets you freely mix on a “per-task” basis code compiled for either the 286’s 64k segmented version of protected mode or the 386’s “native” mode with full 32 bit addressing. (You just need to set up the segment descriptor table appropriately.) Thus it was pretty simple for 386 enhanced mode to “swallow up” Standard Mode and give it a few extra superpowers like virtual memory. But on the flip side this model made it painfully awkward to add native 32 bit components to Win16 software, which is why “Win32s”, that API that added a subset of Win32 calls to Windows 3.1, never really amounted to much.

(It was just barely successful enough to give IBM the fits because it broke how they were virtualizing Windows 3.x under OS/2…)
 
OP,

If you're still interested in this topic, I suggest picking up a copy of one of the first three editions of Charles Petzold's Programming Windows. The memory management chapter explains down to the assembly level how Windows coped with multitasking in real mode, including forcibly moving a program around in memory and fixing up the segment values on the stack. It talks about what simplifying assumptions you can make if your program will only run in protected mode.
 
Back
Top