Roger Turk wrote:
> 
> Clarence,
> 
> I thought that the main difference between .exe and .com files was that the
> .com files had to have a limited length.

Yes, Roger, that is the main reason for having .exe type programs.

Com programs in MSDOS are basically the same as .com programs in CP/M.
They have a 64k size limit (actually 64k -256bytes -2 bytes) and they
at least START with all code, data and stack in the same segment, and
they begin executing right at the first byte - all exactly like CP/M.

The .exes can be pretty much any length - I don't really know if there is
a limit because I'm not into FATware. But that is not the only difference.

Exe code is re-located at load time based on information in the header,
which is a minimum of 512 bytes long, not 256 as I originally said.
The various segments can be spread all through the available memory.
The first byte of executeable code can be anywhere, as the entry point
is specified in the header.

Code, data and stack do not have to all occupy the same segment, but they
are allowed to, so when you assemble a program, and MASM (with the linker)
creates an .EXE, you can convert it to a .COM by running EXE2BIN. 

But this is ONLY possible if a) all segments are declared to be the same,
b) it is less than 64k in length, c) it start execution at 0100h, which
must be the first location in the file, and d) there is no stack defined.

This last business seems all a bit strange if it doesn't matter what the
extension is, but I can't guess what might have been in the minds of the
MSDOS designers when they decided to look at the first 2 bytes of the file
instead of the extension. :(


-  Clarence Verge
--
-  Help stamp out FATWARE.  As a start visit: http://home.arachne.cz/
--

Reply via email to