Hi everybody,
I already asked this question at masm32.com , I hope it's OK with the rules of this forum to ask it here too.

I am a very sentimental guy and I really miss the old MS-DOS... So I have done a bit of research of my own about memory and memory management in real-mode and protected mode environment. I started looking for information about High Memory Area (HMA), Upper Memory Blocks (UMB), eXtended Memory, Expanded Memory, Unreal mode and so on. I think I've got most of the stuff but there are two questions that I was unable to answer:

1. What exactly is UMB? I think that those are RAM blocks accessible through high addresses (above 640K), does this mean that there was more RAM on the motherboard? And when accessing an address above 640K, how the computer "knows" whether I want to access some device mapped memory or just an UMB.

2. I stumbled upon emm386.exe (or emm386.sys) which, as I understand, can simulate Expanded memory using eXtended memory. I would really like to know HOW this is done. What exactly happens when I ask the emm386 expanded memory driver to map some mempry into the frame buffer? What kind of "magic" makes address below 1MB to be mapped into extended memory in real-mode?

I am pretty good in assembly and I am familiar with the 80386 protected mode and its features, so I would really appreciate detailed and technical answers. Please give me links to some technical reading material about the subject and other low-level howto's about the good old DOS days.

Thank you very much in advance,
Posted on 2007-11-17 05:03:33 by realcr
As far as #1 - Before there was XMS there was LIM EMS - LIM stood for Lotus-Intel-Microsoft or some such. EMS was a basic methodology for copying memory from an external device (typically an add-in card I suppose) into and out of the 20-bit address space of the old 16-bit world - I believe that generally there was a specific spot between the 640k mark and the 1 meg mark where this EMS was paged into and out of through BIOS calls. Refer to the Ralf brown Interupt List for more details on this API.

As far as #2 - When running EMM386, you arent in real mode. You are instead in virtual-86 (v86) mode which "looks" like real mode, but isnt. It is more or less protected mode with 16-bit addressing, and the segment selectors are trapped and set correctly to map memory as if you were using a 16-byte stride between segments. The main point of EMM386 was two-fold. One was to simulate EMS when all you had was XMS and the other was to provide further capabilities for mapping memory. Again, refer to Ralf Browns Interrupt List for more details of this API.

You may also want to check out the PMODE "dos extender" which was written by some demo coder who I can't think of the name of right now (Josh something?? he was in the group Renaissance)

To re-iterate: EMS was implimented via memory copying/paging whereas XMS is basically part of a real 32-bit addressing scheme, and emm386 (as well as qemm) creates a protected mode which looks like real mode (called v86 mode)
Posted on 2007-11-17 05:30:08 by Rockoon
PMODE, PMODEW (for watcom C/C++) was written by TRAN of Renaissance. His earlier DOS32 dos extender (predecessor to PMODE)should be more useful for realcr since it was an attempt to extend EMM to a DOS extender status via VCPI. The latter incarnations were combinations of DPMI/VCPI i.e. XMS/EMM.
Posted on 2007-11-19 00:10:29 by Shell
Dont forget http://www.japheth.de

Lots of interesting DOS stuff there, with source code too.
Posted on 2007-11-19 01:10:49 by sinsi
I'm not sure if this is a hoax, but I remember reading that there's a "backdoor" in EMM386 that allows you to escape out of v86 and enter real protected mode, supposedly added for the benefit of windows. I think it was called GEMS or something...
Posted on 2007-11-19 07:32:15 by f0dder
Yes, there is. Otherwise, windows would have no way to start from DOS/EMM386.
But i don't recall how exactly is it called.
Posted on 2007-11-19 09:17:17 by vid