<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=DOS_MZ_executable</id>
	<title>DOS MZ executable - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=DOS_MZ_executable"/>
	<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=DOS_MZ_executable&amp;action=history"/>
	<updated>2026-05-04T20:27:56Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>http://debianws.lexgopc.com/wiki143/index.php?title=DOS_MZ_executable&amp;diff=2359628&amp;oldid=prev</id>
		<title>imported&gt;.galenIgh: /* Compatibility */ wikilink &quot;linkers&quot;</title>
		<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=DOS_MZ_executable&amp;diff=2359628&amp;oldid=prev"/>
		<updated>2024-12-27T23:41:06Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Compatibility: &lt;/span&gt; wikilink &amp;quot;linkers&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Short description|Executable file format used for .EXE files in MS-DOS}}&lt;br /&gt;
{{Refimprove|date=April 2015}}&lt;br /&gt;
{{Use dmy dates|date=July 2019|cs1-dates=y}}&lt;br /&gt;
{{Infobox file format&lt;br /&gt;
| name = DOS MZ executable&lt;br /&gt;
| extension = .[[EXE|exe]], .[[COM file|com]], .[[dynamic-link library|dll]]&lt;br /&gt;
| mime = &lt;br /&gt;
| uniform type = &lt;br /&gt;
| owner = &lt;br /&gt;
| magic = {{code|MZ}}&lt;br /&gt;
| genre = [[Binary file|Binary]], [[executable]]&lt;br /&gt;
| container for = &lt;br /&gt;
| contained by = &lt;br /&gt;
| extended from = &lt;br /&gt;
| extended to = [[New Executable]]&amp;lt;br/&amp;gt;[[Linear Executable]]&amp;lt;br/&amp;gt;[[Portable Executable]]&lt;br /&gt;
| standard = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &amp;#039;&amp;#039;&amp;#039;DOS MZ executable&amp;#039;&amp;#039;&amp;#039; format is the [[executable]] [[file format]] used for .[[EXE]] files in [[DOS]].&lt;br /&gt;
&lt;br /&gt;
The file can be identified by the [[ASCII]] string &amp;quot;MZ&amp;quot; ([[hexadecimal]]: 4D 5A) at the beginning of the file (the &amp;quot;[[Magic number (programming)|magic number]]&amp;quot;). &amp;quot;MZ&amp;quot; are the initials of [[Mark Zbikowski]], one of the leading developers of [[MS-DOS]].&amp;lt;ref&amp;gt;[https://msdn.microsoft.com/en-us/magazine/bb985992.aspx Inside Windows: An In-Depth Look into the Win32 Portable Executable File Format - MSDN Magazine, February 2002] {{Webarchive|url=https://web.archive.org/web/20180711022043/https://msdn.microsoft.com/en-us/magazine/bb985992.aspx |date=2018-07-11  }}. &amp;quot;Every PE file begins with a small MS-DOS executable.&amp;amp;nbsp;... The first bytes of a PE file begin with the traditional MS-DOS header, called an IMAGE_DOS_HEADER. The only two values of any importance are e_magic and e_lfanew.&amp;amp;nbsp;... The e_magic field (a WORD) needs to be set to the value 0x5A4D.&amp;amp;nbsp;... In ASCII representation, 0x5A4D is MZ, the initials of Mark Zbikowski, one of the original architects of MS-DOS.&amp;quot;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The MZ DOS executable file is newer than the [[COM file|COM executable format]] and differs from it. The DOS executable [[Header (computing)|header]] contains [[Relocation (computing)|relocation]] 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 using [[DOS extender]]s.&lt;br /&gt;
&lt;br /&gt;
== Segment handling ==&lt;br /&gt;
&lt;br /&gt;
The environment of an EXE program run by DOS is found in its [[Program Segment Prefix]].&lt;br /&gt;
&lt;br /&gt;
EXE files normally have separate segments for the code, data, and stack. Program execution begins at address 0 of the [[code 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.&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;nasm&amp;quot;&amp;gt;&lt;br /&gt;
    MOV AX, @DATA&lt;br /&gt;
    MOV DS, AX&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
== Termination ==&lt;br /&gt;
&lt;br /&gt;
In the original [[DOS 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:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;nasm&amp;quot;&amp;gt;&lt;br /&gt;
    PUSH DS&lt;br /&gt;
    XOR AX, AX&lt;br /&gt;
    PUSH AX&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The [[DOS 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.&lt;br /&gt;
&lt;br /&gt;
== Compatibility ==&lt;br /&gt;
MZ DOS executables can be run from DOS and [[Windows 9x]]-based operating systems. 32-bit [[Windows NT]]-based operating systems can execute them using their built-in [[Virtual DOS machine]] (although some graphics modes are unsupported). 64-bit versions of Windows cannot execute them. Alternative ways to run these executables include [[DOSBox]] and [[DOSEMU]].&lt;br /&gt;
&lt;br /&gt;
MZ DOS executables can be created by [[Linker (computing)|linkers]], like [[Digital Mars]] [[Optlink]], [[MS linker]], [[VALX]] or [[Open Watcom]]&amp;#039;s WLINK; additionally, [[FASM]] can create them directly.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[DOS]]&lt;br /&gt;
* [[DOS extender]]&lt;br /&gt;
* [[Portable Executable]]&lt;br /&gt;
* [[DOS API]]&lt;br /&gt;
* [[Executable compression]]&lt;br /&gt;
&lt;br /&gt;
==Further reading==&lt;br /&gt;
* {{cite newsgroup&lt;br /&gt;
|title=Re: Run a COM file&lt;br /&gt;
|author-first=Matthias R.&lt;br /&gt;
|author-last=Paul&lt;br /&gt;
|date=2002-10-07&lt;br /&gt;
|orig-year=2000&lt;br /&gt;
|newsgroup=alt.msdos.programmer&lt;br /&gt;
|url=https://groups.google.com/d/msg/alt.msdos.programmer/d7blJjY0H5M/Qu3VeTOIGVcJ&lt;br /&gt;
|access-date=2017-09-03&lt;br /&gt;
|url-status = live&lt;br /&gt;
|archiveurl=https://archive.today/20170903230312/https://groups.google.com/forum/%23!msg/alt.msdos.programmer/d7blJjY0H5M/Qu3VeTOIGVcJ&lt;br /&gt;
|archivedate=2017-09-03}}&lt;br /&gt;
* {{cite web | url=https://groups.google.com/d/msg/alt.lang.asm/PNOd9zfYow0/vXbab16j4XwJ | author=Matthias Paul | date=7 Oct 2002 | title=masm .com(PSP) related trouble | work=alt.lang.asm discussion group }}&lt;br /&gt;
&lt;br /&gt;
* {{cite web | url=https://www.tavi.co.uk/phobos/exeformat.html | author-first=Bob |author-last=Eager | date=16 Dec 2024 | title=Notes on the format of DOS .EXE files | work=PHOBOS reference material |access-date=2024-12-18 }}&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{Reflist}}&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* [https://wiki.osdev.org/MZ OSDev Wiki - MZ format details]&lt;br /&gt;
&lt;br /&gt;
{{Executables}}&lt;br /&gt;
{{Disk operating systems}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Executable file formats]]&lt;br /&gt;
[[Category:DOS technology]]&lt;/div&gt;</summary>
		<author><name>imported&gt;.galenIgh</name></author>
	</entry>
</feed>