WINDOWS executable brief description (2)

zhaozj2021-02-16  46

WINDOWS executable brief description (2)

If the first FCB in the PSP contains an active drive identifier, set the Al to 00h, otherwise 0FFH. MS-DOS also sets AH to 00h or 0FFH, depending on whether the second FCB contains a valid drive identifier.

After the PSP is built, MS-DOS starts immediately (offset 100h) after the PSP loads the COM file, which sets the segment address of the SS, DS, and ES as the PSP, and then create a stack. In order to create this stack, the MS-DOS sets the SP for 0000H. If no 64K memory is assigned, the register is the value of the total number of bytes allocated. Finally, it pushes 0000H to the stack, which is to ensure compatibility with programs designed on early MS-DOS version.

MS-DOS starts the program by transfers the command to pass the commands of 100 h. The programming designer must ensure that the first instruction of the COM file is the entry point of the program.

Note that because the program is loaded at the offset 100h, all code and data offset must also be relative to 100H. Assembly language programmer guarantees this point by 100 h by the initial value of the program (eg, starting at the beginning of the original program) Use statement ORG 100H).

Below is an example of a simple COM file Win32 ASM:

Man struct; define a structure

W DW 1234H; DW can also use word

B DB 9 DUP (?); DB can also be used byte

Man Ends

.MODEL TINY; COM format file

.DATA; For the COM format file, the content of the data segment will automatically put it after the code segment

ZZ Man <>, <1, "abcd">, <3, "ldf">

.code; code segment

.startup; Make the following instructions from 0100h (COM format file requirements)

MOV AX, 3031H

Mov zz.w, AX; assignment to structure

Mov zz.b, '1'

MOV AX, TYPE (MAN); Take the number of bytes of structure

.exit; Setup return code

end

2. MZ format

COM development is the executable of the MZ format, which is the executable file format with the relocation function you can understand. The MZ executable file contains 16-bit code, and the file header is added before these codes, including various description data, such as the first sentence to execute the code execution instruction, the position of the file entry point, the position of the stack, A relocation table, etc., the operating system loads the code portion into the memory according to the information of the file header, and then corrects the code according to the relocation table, and finally begins with the entry specified in the file header after setting the stack. So DOS can put the program in any where it wants. The following figure is a simple structure diagram of the executable of the MZ format:

MZ logo MZ file head other information relocation table byte offset relocation table relocation table can be retransmitted program image binary code

3. In order to maintain the compatibility of DOS and ensure that the MZ format is retained in the MZ format in the NE format that appears in Win 3.x in the NE format in Win 3.x (the specific reasons will be said, here is not described), At the same time, the NE file has added a head that is the executable code of executable file. The 16-bit Windows programs in Win 3.x or OS / 2 probability may be NE format. The NE type includes four types of .dl, .drv and .fon four types of files. The key feature of the NE format is: it isolates program code, data, and resources in different loading blocks. It also implements a so-called execution period dynamic link by symbol input and output. The 16-bit NE Format File Loader (Ne Loader) reads some disk files and generates a completely different data structure and establishes a module in memory. When the code or data needs to be loaded, the loader must assign a piece from the global memory, find where the original data is in the file, find the position, read the original data, and finally do some trims. Also, each 16-bit module is responsible for remembering all segment selectors that are now used, which indicates whether the segment has been abandoned. The following figure is a structural diagram of the executable of the NE format: MS-DOS head DOS file header reserved area Windows header offset DOS STUB program information block NE file head table resource table resident list module reference table introduced name table entry table Resident Name Code Segment and Data Section Reset Table Other: Windows Executive File Brief (1) WONDOWS Executive File Brief (3) ================= ============================================================================================================================================================================================================= ==== Rivershan Original on March 23, 2004 3:38

转载请注明原文地址:https://www.9cbs.com/read-26669.html

New Post(0)