This articleneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources. Unsourced material may be challenged and removed. Find sources: "DOS MZ executable" – news ·newspapers ·books ·scholar ·JSTOR(April 2015) (Learn how and when to remove this message) |
| DOS MZ executable | |
|---|---|
| Filename extension | |
| Internet media type | application/x-dosexec, application/x-msdos-program, application/x-ms-dos-executable |
| Magic number | 4D 5A (MZ inASCII) |
| Type of format | Binary,executable |
| Extended to | New Executable Linear Executable Portable Executable |
TheDOS MZ executable format is theexecutablefile format used for .EXE files inDOS.
The file can be identified by theASCII string "MZ" (hexadecimal: 4D 5A) at the beginning of the file (the "magic number"). "MZ" are the initials ofMark Zbikowski, one of the leading developers ofMS-DOS.[1]
The MZ DOS executable file is newer than theCOM executable format and differs from it. The DOS executableheader containsrelocation information, which allows multiple segments to be loaded at arbitrary memory addresses, and it supports executables larger than 64k; however, the format still requires relatively low memory limits. These limits were later bypassed usingDOS extenders.
The environment of an EXE program run by DOS is found in itsProgram Segment Prefix.
EXE files normally have separate segments for the code, data, and stack. Program execution begins at address 0 of thecode segment, and the stack pointer register is set to whatever value is contained in the header information (thus if the header specifies a 512 byte stack, the stack pointer is set to 200h). It is possible to not use a separate stack segment and simply use the code segment for the stack if desired.
The DS (data segment) register normally contains the same value as the CS (code segment) register and is not loaded with the actual segment address of the data segment when an EXE file is initialized; it is necessary for the programmer to set it themselves, generally done via the following instructions:
MOVAX,@DATAMOVDS,AX
In the originalDOS 1.x API, it was also necessary to have the CS register pointing to the segment with the PSP at program termination; this was done via the following instructions:
PUSHDSXORAX,AXPUSHAX
Program termination would then be performed by a RETF instruction, which would retrieve the original segment address with the PSP from the stack and then jump to address 0, which contained an INT 20h instruction.
TheDOS 2.x API introduced a new program termination function, INT 21h Function 4Ch which does not require saving the PSP segment address at the start of the program, and Microsoft advised against the use of the older DOS 1.x method.
MZ DOS executables can be run from DOS andWindows 9x-based operating systems. 32-bitWindows NT-based operating systems can execute them using their built-inVirtual DOS machine (although some graphics modes are unsupported). 64-bit versions of Windows cannot execute them. Alternative ways to run these executables includeDOSBox andDOSEMU.
MZ DOS executables can be created bylinkers, likeDigital MarsOptlink,MS linker,VALX orOpen Watcom's WLINK; additionally,FASM can create them directly.