An MS-DOS .com file is just raw code/data without header, thus no linking information, and was limited to be loaded into just one segment (64kB). That's the reason corrupted binaries would print "Program too big to fit in memory". But I remember there are .com-files larger than 64kB (some demos?). How did these work? How come they do not produce an error message on loading?
Most large files (over 64KiB) with a
.COM extension are really MZ executables; the DOS loader doesn’t care whether the extension is
.COM, it uses the MZ signature to identify the format. This is the only documented way for a
.COM file larger than 64KiB to work, so it’s the only approach which can be relied upon.
However it is possible to build a
.COM file larger than 64KiB, even though the documented maximum size is 65278 bytes: 65536 bytes addressable without changing segments, minus 256 bytes for the PSP, minus two bytes for the 0-word pushed to the stack (the return address used when exiting a program in DOS 1 style, with a near
RET). When loading with a
.COM file larger than 64KiB, the behaviour depends on the specific variant and version of DOS in use:
early versions of MS-DOS only read the first 64KiB;
by MS-DOS 5 if not earlier (and presumably corresponding versions of PC DOS), the implementation sticks to the specification, and complains that the program is “too big to fit in memory” (version 6) or simply that it “cannot execute ...” (version 5);
DR DOS and OpenDOS load the program in its entirety, if it fits into available memory, and start execution as normal.
Care must be taken because DOS will initialise the stack to start at the end of the 64KiB block the program is assumed to occupy, which means part of the binary’s image in memory will be overwritten. Typically one of the first things such a program would do, would be to move its stack... All the segment operations required to access anything outside the first 64KiB also have to be calculated manually.
This was supposed to be documented in release 62 of Ralf Brown’s Interrupt List, and there’s a thread on the topic on