Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z
faqs.org - Internet FAQ Archives

comp.os.msdos.programmer FAQ part 2/5
Section - - What's the difference between .COM and .EXE formats?

( Part1 - Part2 - Part3 - Part4 - Part5 - Single Page )
[ Usenet FAQs | Web FAQs | Documents | RFC Index | Business Photos and Profiles ]


Top Document: comp.os.msdos.programmer FAQ part 2/5
Previous Document: - What's the format of an .EXE header?
Next Document: - How do I create a .COM file?
See reader questions & answers on this topic! - Help others by sharing your knowledge

 To oversimplify: a .COM file is a direct image of how the program will
 look in main memory, and a .EXE file will undergo some further
 relocation when it is run (and so it begins with a relocation header). A
 .COM file is limited to 64K for all segments combined, but a .EXE file
 can have as many segments as your linker will handle and be as large as
 RAM can take.

 The actual file extension doesn't matter. DOS knows that a file being
 loaded is in .EXE format if its first two bytes are MZ or ZM; otherwise
 it is assumed to be in .COM format. For instance, DR-DOS 6.0's
 COMMAND.COM is in .EXE format as is COMMAND.COM in recent versions of
 MS-DOS.

 Reader Paul Schylter posted this description of .COM files vs. .EXE
 files to the newsgroup in message <a3rpp8$a9h$1@merope.saaf.se>:

 "Actually they must be less than 0xFF00 bytes long, since the PSP, which
 isn't included in the COM file but is within those 64K, is 256 bytes
 long.

 "Then CAN use many segments, but they don't have to. In particular, any
 .COM file can be converted to an .EXE file by adding an appropriate
 header to it.

 "There are some other differences between a .COM file and a single
 segment .EXE file (both of which must be smaller than 64K):

 "The entry point of the .COM file is _always_ 0x100, while the entry
 point of the .EXE file can be at any address.

 "The stack size of the .COM file is the remainder of those 64K which
 isn't used by the code image, while the stack size if the single segment
 .EXE file can be set at any size as long as it fits within those 64K.
 Thus the stack can be smallere in the .EXE file.

 "When a COM file is loaded, the entire TPA (= "free memory") of MS-DOS
 is allocated for that COM file -- including those parts of the TPA which
 are outside the 64k of the COM file. If you don't want this (e.g.
 because your COM file is a TSR and you want to load other programs
 later), you must explicitly free those parts of the TPA you want freed.
 In the header of an .EXE file you can specify how large part of the TPA
 that .EXE file should receive."

User Contributions:

Comment about this article, ask questions, or add new information about this topic:

CAPTCHA




Top Document: comp.os.msdos.programmer FAQ part 2/5
Previous Document: - What's the format of an .EXE header?
Next Document: - How do I create a .COM file?

Part1 - Part2 - Part3 - Part4 - Part5 - Single Page

[ Usenet FAQs | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
jeffrey@carlyle.org (Jeffrey Carlyle)





Last Update March 27 2014 @ 02:11 PM