Generated by DeepSeek V3.2| COM | |
|---|---|
| Name | COM |
| Extension | .com |
| Mime | application/x-msdos-program |
| Uniform type | com.dos.executable |
| Owner | Digital Research, Microsoft |
| Released | 0 1976 |
| Genre | Executable |
| Extended to | .exe |
COM. The COM file format is a simple type of executable program file originally used in the CP/M operating system and later widely adopted by MS-DOS and early versions of Microsoft Windows. It consists of raw binary machine code with a maximum size of 64 KB, loaded directly at a fixed memory address without a formal header. This simplicity made it the standard for small utilities and bootstrapping code during the early microcomputer era, though it was eventually superseded by the more complex and flexible .exe format.
The COM format is characterized by its lack of a metadata header, meaning the file contains pure x86 machine instructions and data intended to be loaded at offset 0100h within a specific memory segment. This design imposed a strict 65,535-byte size limit, as it occupied a single segment of memory under the Intel 8086 architecture. Its execution model required the CPU instruction pointer to begin at the first byte of the file, making program organization entirely the responsibility of the developer. Due to this straightforward structure, COM files were the default output for many early assemblers and compilers targeting the IBM PC platform, and they remain executable in modern command-line environments like the Windows Command Prompt through built-in compatibility layers.
Technically, a COM file is a direct memory image where the first executable instruction resides at the very beginning of the file, with all code, data, and a stack required to fit within one 64 KB segment. Upon loading, the DOS program loader sets the segment registers (CS, DS, SS, and ES) to point to the Program Segment Prefix (PSP), a 256-byte control block placed just before the program's code in memory. The IP register is set to 0100h, and execution commences. Because it lacks relocation information, all address references must be made relative or calculated at runtime, and the program must manage its own memory if it needs to exceed the segment boundary. This contrasts sharply with the Microsoft .exe format, which includes a relocation table and allows for multiple segments and larger programs.
The COM format originated with the CP/M operating system created by Digital Research in the mid-1970s, where it served as the standard executable type for the Intel 8080 and Zilog Z80 processors. When Microsoft developed MS-DOS, it adopted the COM format for compatibility and simplicity, leveraging the similar memory models of the Intel 8086. Early notable software distributed as COM files includes utilities like DEBUG and EDLIN, as well as many games for the IBM PCjr. The introduction of the DOS .exe format with MS-DOS 2.0 in 1983 began its decline, as larger applications like Lotus 1-2-3 and WordStar required the expanded capabilities. However, COM files persisted for boot loaders, Terminate-and-Stay-Resident programs, and simple scripts well into the Windows 95 era.
Primary historical applications for COM files included small system utilities, batch file companions, and hardware diagnostic tools distributed with operating systems like PC DOS and DR-DOS. They were essential for bootstrapping sequences, where a compact boot sector might load a secondary COM file to initialize an OS kernel. During the peak of the Shareware movement in the late 1980s and early 1990s, many simple games and applications were distributed as COM files due to their ease of creation and minimal overhead. In modern contexts, the format is largely obsolete but is still supported for backward compatibility within virtual machines and emulators like DOSBox, and it is sometimes used in embedded systems programming and security research involving legacy code.
Several variants and related executable formats evolved from or coexisted with the classic COM file. The .exe format, specifically the MZ executable introduced with MS-DOS, was its direct successor, adding a header and relocation support. The COM port, a serial hardware interface, shares the acronym but is unrelated. In other operating systems, similar raw binary formats exist, such as BBC Micro's executable images and certain ROM images for vintage consoles like the Nintendo Entertainment System. The conceptual simplicity of COM also influenced the design of later formats for firmware and BIOS extensions. Furthermore, some computer viruses of the 1980s, such as the Cascade virus, specifically targeted the COM file structure to propagate, exploiting its predictable loading address.