开发者

Question about "Link Map" output and "Assume" directive of MASM assembler

开发者 https://www.devze.com 2022-12-25 19:57 出处:网络
I am new to MASM. So the questions may be quite basic. When I am using the MASM assembler, there\'s an output file called \"Link Map\". Its content is composed of the starting offset and length of va

I am new to MASM. So the questions may be quite basic.

When I am using the MASM assembler, there's an output file called "Link Map". Its content is composed of the starting offset and length of various segments, such as Data segment, Code segment and Stack segment. I am wondering that, where are these information describing? Are they talking about how various segment开发者_开发技巧s are located within an EXE file or, how segments are located within memory after the EXE file being loaded into memory by a program loader?

BTW: What does the "Assume" directive do? My understanding is that it tell the assembler to emit some information into the exe file header so the program loader could use it to set DS, CS, SS, ES register accordingly. Am I right on this?

Thanks in advance.


Linker map

this is not MASM specific. It is part of the linker. I.e.

ml /Fm foo.asm

is the same as

ml foo.asm /link /map

or

ml /c foo.asm
link foo.obj /map

cl.exe has this option too (/Fm) which does the same thing.

It is a list of the sections that are placed in the EXE or DLL image, in the order they appear. E.g. code, data, resources, import table, export table, etc.

The offset is relative to the start of the image section. A number of object sections may be combined into an image section by the linker.

E.g.

 0002:00001514 00000014H .idata$2                DATA
 0002:00001528 00000014H .idata$3                DATA
 0002:0000153c 000000f8H .idata$4                DATA
 0002:00001634 00000464H .idata$6                DATA

The above are object sections (they come from .obj files) since they contain a suffix starting with $. The linker will merge them into one section .idata in the final image module (in lexicographic order of the suffix). The offset is relative to the start of where the linker will allocate the import address table (.idata section).

Assume

Provides compile-time checks, to prevent accidental misuse of registers. It doesn't generate any code. See

  • http://www.arl.wustl.edu/~lockwood/class/cs306/books/artofasm/Chapter_8/CH08-3.html#HEADING3-98
  • http://msdn.microsoft.com/en-us/library/kx3dscek(VS.80).aspx
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号