Automatic Linking

The ML.EXE translator provides the convenient feature of automatically starting the linker. As a rule, this feature is ignored using the /c command-line option. If this option isn't used, the ML compiler will try to start the LINK.EXE program. To correctly compile and link the program, it is necessary to specify the required options of the linker. Thus, the entire command line would appear as follows :

 ML /coff prog.asm /LINK /subsystem:windows 

Very convenient, isn't it?

Self-Translating Program

There exists one interesting technique that allows you to format the program source code to make it possible to start it as a BAT file, which would immediately assemble and link the program. This technique is possible because the command processor ignores the semicolon character (;). At the same time, the assembler uses this character for marking the comments. Thus, you can always mask the OS commands from the assembler's view. Listing 5.1 is a skeleton for such a program. Do not forget that the file must have the BAT filename extension. For this example, name your program M.BAT.

Listing 5.1: A self-assembling and self-linking program
image from book
 ; goto masm ; Program code here . . . END START ; ml /c /coff M.BAT ; link /subsysytem:windows M.OBJ 
image from book
 

That's all. Of course, this is a trifle; however, the art of programming consists of such small details.



The Assembly Programming Master Book
The Assembly Programming Master Book
ISBN: 8170088178
EAN: 2147483647
Year: 2004
Pages: 140
Authors: Vlad Pirogov

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net