DOS executable (.com)

From Just Solve the File Format Problem
(Difference between revisions)
Jump to: navigation, search
(Introduction)
m
Line 6: Line 6:
 
}}
 
}}
 
==Introduction==
 
==Introduction==
On DOS and early Windows systems, files with extension .com are a special type of 16 bit executable which most of the time can only be run from the commandline. The extension comes from [[CP/M]] and stands for "command program" (or some variant thereof). As such they predate the more common [[EXE]] format, and are quite limited compared to the newer format:
+
On DOS and early Windows systems, files with extension .com are a special type of 16 bit executable which most of the time can only be run from the commandline. The extension comes from [[CP/M]] and stands for "command program" (or some variant thereof). As such they predate the more common [[MS-DOS EXE|EXE]] format, and are quite limited compared to the newer format:
 
*COM files contain only one area of combined code and data. There is no segmentation, no seperate code and data segments, and (more importantly) no relocation table
 
*COM files contain only one area of combined code and data. There is no segmentation, no seperate code and data segments, and (more importantly) no relocation table
 
*They contain the raw program binary, without any header, which will be mapped into memory at a specific offset (<code>0x100</code>) in a (possibly random) segment. Thus they resemble some arbitrary [[ROM]] (.bin) format.
 
*They contain the raw program binary, without any header, which will be mapped into memory at a specific offset (<code>0x100</code>) in a (possibly random) segment. Thus they resemble some arbitrary [[ROM]] (.bin) format.
Line 15: Line 15:
 
Since COM files contain directly executable code, most of them start with a simple <code>0xe9</code> or <code>oxeb</code> byte, representing a short JUMP to the "real" entry point of the program. But this is not set in stone, and there are lots of COM files that have a different first byte.
 
Since COM files contain directly executable code, most of them start with a simple <code>0xe9</code> or <code>oxeb</code> byte, representing a short JUMP to the "real" entry point of the program. But this is not set in stone, and there are lots of COM files that have a different first byte.
  
Sometimes, COM files are larger than 64kb and start with a "MZ" or "ZM" signature in the first 2 bytes. These are in fact simply renamed [[EXE]] files, the original DOS kernel did not care about the file extension but only looked at the first 2 bytes to determine the file format (COM or EXE) of the program to be run.
+
Sometimes, COM files are larger than 64kb and start with a "MZ" or "ZM" signature in the first 2 bytes. These are in fact simply renamed [[MS-DOS EXE|EXE]] files, the original DOS kernel did not care about the file extension but only looked at the first 2 bytes to determine the file format (COM or EXE) of the program to be run.
  
 
==References==
 
==References==

Revision as of 02:33, 9 May 2014

File Format
Name DOS executable (.com)
Ontology
Extension(s) .com
MIME Type(s) application/octet-stream

Introduction

On DOS and early Windows systems, files with extension .com are a special type of 16 bit executable which most of the time can only be run from the commandline. The extension comes from CP/M and stands for "command program" (or some variant thereof). As such they predate the more common EXE format, and are quite limited compared to the newer format:

  • COM files contain only one area of combined code and data. There is no segmentation, no seperate code and data segments, and (more importantly) no relocation table
  • They contain the raw program binary, without any header, which will be mapped into memory at a specific offset (0x100) in a (possibly random) segment. Thus they resemble some arbitrary ROM (.bin) format.
  • They can be at most around 64kb big (65280 bytes to be exact)
  • They can only use relative adressing, since the position in memory where they are loaded is not known to the program (but can be determined through an API call)

A good example is command.com, the 16 bit command line interface of MS-DOS.

Since COM files contain directly executable code, most of them start with a simple 0xe9 or oxeb byte, representing a short JUMP to the "real" entry point of the program. But this is not set in stone, and there are lots of COM files that have a different first byte.

Sometimes, COM files are larger than 64kb and start with a "MZ" or "ZM" signature in the first 2 bytes. These are in fact simply renamed EXE files, the original DOS kernel did not care about the file extension but only looked at the first 2 bytes to determine the file format (COM or EXE) of the program to be run.

References

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox