fbpx
Wikipedia

DOS MZ executable

The DOS MZ executable format is the executable file format used for .EXE files in DOS.

DOS MZ executable
Filename extension
.exe, .com, .dll
Internet media typeapplication/x-dosexec, application/x-msdos-program
Magic numberMZ
Type of formatBinary, executable
Extended toNew Executable
Linear Executable
Portable Executable

The file can be identified by the ASCII string "MZ" (hexadecimal: 4D 5A) at the beginning of the file (the "magic number"). "MZ" are the initials of Mark Zbikowski, one of the leading developers of MS-DOS.[1]

The MZ DOS executable file is newer than the COM executable format and differs from it. The DOS executable header contains 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 extenders.

Segment handling Edit

The environment of an EXE program run by DOS is found in its Program Segment Prefix.

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.

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:

 MOV AX, @DATA  MOV DS, AX 

Termination Edit

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:

 PUSH DS  XOR AX, AX  PUSH AX 

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.

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.

Compatibility Edit

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.

MZ DOS executables can be created by linkers, like Digital Mars Optlink, MS linker, VALX or Open Watcom's WLINK; additionally, FASM can create them directly.

See also Edit

Further reading Edit

  • Paul, Matthias R. (2002-10-07) [2000]. "Re: Run a COM file". Newsgroup: alt.msdos.programmer. Archived from the original on 2017-09-03. Retrieved 2017-09-03.
  • Matthias Paul (2002-10-07). "masm .com(PSP) related trouble". alt.lang.asm discussion group.

References Edit

  1. ^ Inside Windows: An In-Depth Look into the Win32 Portable Executable File Format - MSDN Magazine, February 2002 2018-07-11 at the Wayback Machine. "Every PE file begins with a small MS-DOS executable. ... 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. ... The e_magic field (a WORD) needs to be set to the value 0x5A4D. ... In ASCII representation, 0x5A4D is MZ, the initials of Mark Zbikowski, one of the original architects of MS-DOS."

External links Edit

  • OSDev Wiki - MZ format details

executable, this, article, needs, additional, citations, verification, please, help, improve, this, article, adding, citations, reliable, sources, unsourced, material, challenged, removed, find, sources, news, newspapers, books, scholar, jstor, april, 2015, le. This article needs additional citations for verification Please help improve this article by adding 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 template message The DOS MZ executable format is the executable file format used for EXE files in DOS DOS MZ executableFilename extension exe com dllInternet media typeapplication x dosexec application x msdos programMagic numberMZType of formatBinary executableExtended toNew ExecutableLinear ExecutablePortable ExecutableThe file can be identified by the ASCII string MZ hexadecimal 4D 5A at the beginning of the file the magic number MZ are the initials of Mark Zbikowski one of the leading developers of MS DOS 1 The MZ DOS executable file is newer than the COM executable format and differs from it The DOS executable header contains 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 extenders Contents 1 Segment handling 2 Termination 3 Compatibility 4 See also 5 Further reading 6 References 7 External linksSegment handling EditThe environment of an EXE program run by DOS is found in its Program Segment Prefix 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 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 MOV AX DATA MOV DS AXTermination EditIn 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 PUSH DS XOR AX AX PUSH AX 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 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 Compatibility EditMZ 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 MZ DOS executables can be created by linkers like Digital Mars Optlink MS linker VALX or Open Watcom s WLINK additionally FASM can create them directly See also EditDOS DOS extender Portable Executable DOS API Executable compressionFurther reading EditPaul Matthias R 2002 10 07 2000 Re Run a COM file Newsgroup alt msdos programmer Archived from the original on 2017 09 03 Retrieved 2017 09 03 Matthias Paul 2002 10 07 masm com PSP related trouble alt lang asm discussion group References Edit Inside Windows An In Depth Look into the Win32 Portable Executable File Format MSDN Magazine February 2002 Archived 2018 07 11 at the Wayback Machine Every PE file begins with a small MS DOS executable 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 The e magic field a WORD needs to be set to the value 0x5A4D In ASCII representation 0x5A4D is MZ the initials of Mark Zbikowski one of the original architects of MS DOS External links EditOSDev Wiki MZ format details Retrieved from https en wikipedia org w index php title DOS MZ executable amp oldid 1174837991, wikipedia, wiki, book, books, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.