COM file

It is very simple; it has no header (with the exception of CP/M 3 files),[2] and contains no standard metadata, only code and data.

Under CP/M, the first 256 bytes of this memory, from 0000h to 00FFh were reserved for system use by the zero page, and any user program had to be loaded at exactly 0100h to be executed.

It is possible to make a .COM file to run under both operating systems in form of a fat binary.

Since C9h is the opcode for LEAVE since the 80188/80186 and therefore not used as the first instruction in a valid program, the executable loader in some versions of DOS rejects COM files that start with C9h, avoiding a crash.

This leaves the possibilities that the COM file can either be very simple, using a single segment, or arbitrarily complex, providing its own memory management system.

[5] Once compilers and linkers of sufficient power became available, it was no longer advantageous to use the .COM format for complex programs.

The format is still executable on many modern Windows NT-based platforms, but it is run in an MS-DOS-emulating subsystem, NTVDM, which is not present in 64-bit variants.

Windows NT-based operating systems use the .com extension for a small number of commands carried over from MS-DOS days although they are in fact presently implemented as .exe files.

The operating system will recognize the .exe file header and execute them correctly despite their technically incorrect .com extension.

For example, if a directory in the system path contains two files named foo.com and foo.exe, the following would execute foo.com: A user wishing to run foo.exe can explicitly use the complete filename: Taking advantage of this default behaviour, virus writers and other malicious programmers have used names like notepad.com for their creations, hoping that if it is placed in the same directory as the corresponding EXE file, a command or batch file may accidentally trigger their program instead of the text editor notepad.exe.

Unwary Microsoft Windows users clicking on such an attachment would expect to begin browsing a site named http://www.example.com/, but instead would run the attached binary command file named www.example, giving it full permission to do to their machine whatever its author had in mind.

A number of COM files in IBM PC DOS 1.0