Compiling and executing assembly language programs

This section discusses the basics of generating an executable file from an Assembly language source code file. There is also a discussion of the compiler options of conditional assembly and macros.

With the older versions of Microsoft Assemblers, there are two basic steps used to generate an executable file to run under DOS. The first step is to compile the Assembly language source code into an object file. The second step is to link the object file with any other object files necessary and any needed library routines to generate the executable file. With the new version of Microsoft Assembler, you can compile and link with a single command.

The following examples use the Microsoft Macro Assembler (ML) for compiling and linking operations. When using ML to compile Assembly language code, there are four default filename extensions used for the files. These are .ASM for the Assembly language file, .OBJ for the object files, .LIB for the library files, and .EXE for the executable file.


Instructions for compiling a program are specific to the compiling software product and there may be many different options. A simple way to compile is to enter the following at the DOS prompt:
ML filename.ASM

This command performs a standard compile of the file with a .ASM extension and produces a file with the same name but with a .EXE extension that can be executed. An example of a command line with a compiler option follows:
ML /Fl filename.ASM

The /Fl is used to generate an Assembly language code listing which is helpful for finding program errors. The compiling phase is where you find most of the spelling and syntax errors.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.