CMD file (CP/M)
| Company type | File extension |
|---|---|
| Industry | Computing / Operating systems |
| Products | Executable files for CP/M-86 and batch scripts for OS/2 and Windows |
In operating systems such as CP/M-86, Concurrent CP/M-86, Personal CP/M-86, S5-DOS, DOS Plus, Concurrent DOS, FlexOS, Multiuser DOS, System Manager, and REAL/32, along with SCP1700, CP/K, and K8918-OS, the filename extension CMD designates executable files following the CP/M format. This extension is analogous to the COM files in CP/M-80 and EXE files in DOS. Additionally, the command interpreter CMD.EXE in both OS/2 and Windows employs the same .CMD extension for its batch script files.
Binary format
A CMD executable begins with a 128-byte header, succeeded by between one and eight segments containing either code or data. Each segment may have a maximum size of one megabyte. More recent iterations incorporate relocation data and support for Resident System Extensions (RSXs).
The header specifies which segments are included and their respective categories, with each category appearing only once:
- Code
- Data
- Extra
- Stack
- User 1
- User 2
- User 3
- User 4
- Shared Code (note that Code and Shared Code segments cannot be present simultaneously).
The initial 256 bytes within the data segment must be zero-filled; this area is initialized by CP/M-86 as the zero page, comparable to the Program Segment Prefix used in DOS. If the data segment is absent, these first 256 bytes are taken from the code segment instead.
Name conflict
On platforms like OS/2 and Windows NT, the .CMD suffix is linked to batch files executed by their command interpreter, CMD.EXE. Executable CMD files created for CP/M-86 are incompatible with this interpreter but generally only result in minimal issues. To differentiate between these binary CMD executables and batch scripts, the CP/M-86 loader examines the initial byte (known as the type byte); since batch scripts rarely contain ASCII characters below decimal 10, this check effectively prevents misinterpretation.