EXE format file under DOS

xiaoxiao2021-03-06  21

Author: Hong pity to upload 2003-9-12

Generate the EXE format file; Model pseudo-operated format is: modl Memory_Mode, Model_Options where: Memory can be compiled into a COM format file for Tiny / Small / Medium / Compact / Large / HUGE / FLAT, etc., other exe formats The file small is one of the more commonly used, so this is explained here for small, all data is placed in a 64K segment, and all the code is placed in another 64K segment, and the data and code are near access.

-------------------------------------------------- ------------------; Example: Display a string; file name: 2.ASM, generate file 2.exe .Model small after compiling the link; generate the EXE format file. Stack 100H; If no 100h, the default stack size is 400h .data; the initialized data segment mess db 'how, world! $' .data?; Not initialized data segment, this paragraph does not occupy the size of the EXE file! PP DW 200H DUP (?); for unmelified data, can only be used "?" .code; code segment .startup; can initialize DS and stack values ​​(Examples of reflection) MOV AH, 9 Lea DX , Mess Int 21h, display information MOV PP, ax .exit; can set return code END; because it is used .Startup, don't need to indicate where the program starts! -------------------------------------------------- ------------ Detailed operation of the 2.exe file: D: / masm615> DIR 2 Volume In Drive D Has No Labelvolume Serial Number IS 18F0-186BDIRECTORY OF D: / MASM6152 ASM 711 02-15-03 10:48 2.ASM 1 File (s) 711 Bytes 0 Dir (s) 2,408,906,752 bytes freed: / masm615> ml 2.asmmicrosoft (r) macro assembler version 6.15.8803 patched for you by Promethee [ECL ] in the year 2001 - enjoyCopyright (C) Microsoft Corp 1981-2000 All rights reserved.Assembling:.. 2.asmMicrosoft (R) Segmented Executable Linker Version 5.60.339 Dec 5 1994Copyright (C) Microsoft Corp 1984-1993 All rights reserved .Object modules [.objrun file [2.exe]: "2.exe" list file [Nul.map]: nullibraries [.lib]: definitions file [Nul.def]: d: / masm615>

Dir 2Volume In Drive D Has No Labelvolume Serial Number IS 18F0-186BDIRECTORY D: / MASM6152 ASM 711 02-15-03 10:48 2.asm2 Obj 207 02-15-03 10:50 2.obj2 EXE 562 02-15 -03 10:50 2.exe 3 file (s) 1,480 bytes 0 dir (s) 2,408,910,848 bytes freeD: / Masm615> 2How, world D:! / Masm615> ________________________________________________________________ view DEBUG EXE file generated by -rAX = 0000 BX = 0000 cx = 0032 dx = 0000 SP = 0100 bp = 0000 Si = 0000 di = 0000DS = 128C ES = 128C SS = 12A0 CS = 129C IP = 0000 NV UP EI PL NZ NA PO NC129C: 0000 ba9e12 MOV DX, 129E- U0 25129C: 0000 Ba9E12 MOV DX, 129E; this is 129C: 0003 8eda MOV DS, DX; setting data segment (initialization data and uninitialized data) 129c: 0005 8CD3 MOV BX, SS129C: 0007 2BDA SUB BX, DX129C: 0009 D1E3 SHL BX, 1129C: 000B D1E3 SHL BX, 1129C: 000D D1E3 SHL BX, 1129C: 000f D1E3 SHL BX, 1129C: 0011 FA CLI129C: 00 12 8ed2 MOV SS, DX; Reset Stack 129c: 0014 03E3 Add SP, BX; This, DS = SS129C: 0016 FB STI129C: 0017 B409 MOV AH, 09; This is the program we wrote 129c: 0019 8D160600 LEA DX [0006] For small, the positioning type of data is Word, that is, the number of even numbers, such as 6129c: 001D CD21 INT 21129C: 001F A32001 MOV [0120], AX; unmected data is located behind "code / data / stack" 129C: 0022 B44C MOV AH, 4C129C: 0024 CD21 INT 21-D129E: 6 11129E: 0000 48 6F-77 2C 20 77 6F 72 6C 64 How, World129e: 0010 21 24! $ - G17AX = 0000 bx = 0020 CX = 0032 Dx = 129e sp = 0120 bp =

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

New Post(0)