The Assembly Programming Master Book

Now, it is time to test all the programs presented in this chapter by translating them using TASM.

The situation is easy for the programs shown in Listings 1.1 and 1.2. To translate them, it is sufficient to execute the following commands:

TASM32 /ml PROG1.ASM TLINK32 -aa PROG1.OBJ

Now, proceed with translation of the PROG2.ASM and PROG1.ASM modules provided in Listings 1.3 and 1.4, respectively. Object modules are created without difficulties. Viewing the PROG2.OBJ module, you'll notice that the external procedure is represented by a simple name PROC1. Consequently, the only thing that you should do is replace the PROC1@0 name with PROC1 in the PROG1.ASM module. Further linking of the modules also is straightforward:

TLINK32 -aa PROG1.OBJ PROG2.OBJ

For working with libraries, TASM provides a librarian TLIB.EXE. Issuing the following command creates a library from the PROG2.OBJ module:

TLIB LIB1.LIB + PROG2.OBJ

As a result, the library named LIB1. LIB will appear on the disk. It is necessary to link the PROG 1.OBJ module to this library:

TLINK32 -aa PROG1, PROG1, PROG1, LIB1

As a result, you'll get the PROG1.EXE executable module.

You should pay close attention to the TLINK32 command-line option. In the most general form, it looks as follows : [i]

TLINK32 -aa OBJFILES, EXEFILE, MAPFILE, LIBFILES

In TASM, there is no INVOKE directive; therefore, I'll avoid using it later. [ii]

When introducing this book, I declared my intention to reconcile two assemblers. Since the differences between them mainly lie in directives and macro commands (see Chapter 5), a simple idea suggests itself, namely, that it is possible to achieve compatibility by simply avoiding such directives and macro commands. The basis of the Windows program is formed by API calls (see Chapter 2). As you know already, the difference in calls to the external procedure is that the names for MASM have @N suffix. Here, it is impossible to do without macro definitions. These aspects will be considered in due time.

[i] Note that this form is slightly simplified.

[ii] My opinion is that nothing can be better than manually loading parameters into the stack.

Категории