Subject: DOS Memory Models

From: [email-masked] (Chrisopher E. Reid)
Date: Wed, 19 Oct 94 09:34:26 -0400

Hello,

DOS is really arcane.
To clear the confusion on DOS memory models here are the facts
about DOS memory models:

            Addressing Scheme
Model        Data       Code

Huge        20 bits     16 + 4
Large       16 + 4      16 + 4
Medium      16 + 4      16
Small       16          16

In the huge model the addressing is always 20 bits for data
(1 Megabyte) and segmented (16 + 4) for code. The segmentation
means there are 20 effective address bits, but they are split across
two 16-bit words with the high 4 bits in a second word. In the
Huge model these 20 bits are handled as one unit for data.
Actually it is even worse because the segment address is a full
16 bit word addressing memory in 16-byte chunks. The offset is
another full 16 bit word which gives the offset from the segment
address. Thus there are many possible addresses for the same location.

In the Large model the same 20 bits are used, but the 16 bit
offset and 4 bit segment portions are independent of eachother.
Effectively this means that any one segment can hold at most
64 KB. An overflow of the 16 bit offset portion does NOT change
the segment portion, it is simply an overflow. The Huge model
fixes this, but it is slower because every time pointer arithmetic
is performed a special routine must be called to take care of
possible overflow.

Finally, in standard old DOS no program can access more than
640K in any case. Windows 3.1 allows access to 16 Megabytes,
but that takes special coding by the programmer. Windows 3.1 with
the Win32s extensions provides a flat 32-bit memory space and
makes 4.4 gigabytes available without special coding. Most machines
do not have that much memory.

Windows NT and Chicago (Windows 95) both support a flat 32-bit
memory space.

In short: Yes, I'm sure the problems with the parser are memory
limitations imposed by DOS.

Chris