Wednesday 16 November 2011

What is the benefit of a .COM file over an .EXE file? in C programming

What is the benefit of a .COM file over an .EXE file?

A .COM file is limited to 64KB for all code, data, and stack storage and therefore is limited to smal lapplications such as utility programs and TSRs (terminate-and-stay-resident programs). One distinct
advantage of a .COM file over an .EXE file is that .COM files load faster than .EXE files.

A .COM file is also known as a “memory image” file because it is loaded directly into memory with no required “fixups.” An .EXE file contains special fix-up instructions inserted by the linker into the file’s header. These instructions include a relocation table used to manage the different parts of the executable program. A .COM file does not contain any of these instructions or a relocation table, because the entire program can fit into 64KB. Thus, DOS does not need to parse through any fix-up code, and the .COM file loads faster than an .EXE file. 

.COM files are usually simplistic and are somewhat limited in what they can accomplish. For instance, you cannot allocate memory from the far heap from a .COM file.

Cross Reference:

XVIII.5: How do you create a .COM file?

No comments:

Post a Comment