CMD file (CP/M)

From Wikipedia, the free encyclopedia
Jump to: navigation, search

In 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, CMD is the filename extension used by CP/M-style executable programs. It corresponds to COM in CP/M-80 and EXE in DOS. The same extension is used by the command-line interpreter CMD.EXE in OS/2 and Windows for batch files.

Binary format[edit]

A CMD file has a 128-byte header, followed by 1-8 groups of code or data. Each group can be up to 1 megabyte in size. In later versions of the format, CMD files can also contain relocation information and Resident System Extensions (RSXs).

The start of the header lists the groups present in the file, and their types. Each type can be used at most once; they are:

  1. Code
  2. Data
  3. Extra
  4. Stack
  5. User 1
  6. User 2
  7. User 3
  8. User 4
  9. Shared Code (Code and Shared Code cannot be present in the same file).

The first 256 bytes of the data group must be zero. They will be populated by CP/M-86 with the zero page (comparable to the Program Segment Prefix in DOS). If there is no data group, then the first 256 bytes of the code group will be used instead.

Name conflict[edit]

Under OS/2 and Windows NT the .CMD file extension is associated with batch scripts for their command processor CMD. Since binary code will not be executed this way, attempting to run CP/M-86 CMD files under the CMD command processor will not work, but typically only cause mild inconvenience to users. The executable loader and relocator in CP/M-86 and related operating systems can test the first byte in the file, which happens to be the type byte of the first table entry in a CP/M CMD file, to have a value of 1 to 9 before accepting it as a valid CP/M CMD file. ASCII values smaller than 10 are rarely or never used in batch scripts, so that this scheme gives reasonably good protection.

External links[edit]