Getting Started

You've just bought the book, and you need to get the Microsoft Assembler and sample programs installed so you can start working. Great!

Sorry, but we cannot legally distribute the MASM assembler, which may be a problem for you if you no longer have the CDROM that was enclosed with the book.

I you have the CDROM, run the installation program now.

Step 1

From Windows Explorer, choose Refresh from the View menu, and look for the following files in the C:\MASM613 directory:

Of course, there are lots of other files, but these are the only ones you need to know about right now.

Step 2

You're going to test the Microsoft assembler now, to make sure it works. Open up an MS-DOS (command prompt) window. To do this, select Run from the Start menu, type command, and click OK.

Step 3

In the MS-DOS window, type the following commands, pressing Enter after each line:

cd \Masm613

make16 hello

You should see the following messages appear on the screen (the numbers and dates may be different, but you get the idea):

 Assembling: hello.asm
Volume in drive C is ...
Volume Serial Number is ...
 Directory of C:\MASM613
10/31/2001 07:25p 353   hello.asm
10/31/2001 07:44p 3,208 HELLO.EXE
10/31/2001 07:44p 2,098 hello.lst
10/31/2001 07:44p 281   HELLO.MAP
10/31/2001 07:44p 492   hello.obj

Several files (hello.exe, hello.lst, hello.map, and hello.obj) were created. The date and time of these files should match your own current date and time.

Step 4

Run the hello.exe program by typing the following and pressing Enter:

hello

And the program should display "Hello World" on the screen.

Step 5

Now we'll show you how to to assemble and run the same program from your own working directory. Here's what to do, in three sequential steps:

1. Create a working directory on your hard drive, where you plan to write all of your programs. You can choose any directory name that's 8 characters or less. For example, let's call it C:\MyASM. See our important note about directory names.

2. Copy the following three files to the C:\MyASM directory: hello.asm, make16.bat, and runCV.bat

3. Type the following commands at the MS-DOS (Command) prompt:

cd \MyASM
make16 hello
hello

The program should assemble and run just as it did before. From now on, whenever you create an assembly language source file in the C:\MyASM directory, you can use the make16 command to assemble and link the program.

Writing Your Own Programs

You can use almost any text editor to write assembly language programs. Some examples are:

If you explore our web site, you can read additional help related to using MASM with TextPad and Microsoft Visual C++. See our important note about MS-DOS filenames.

This ends the Getting Started tutorial. Would you like to learn how to use the CodeView debugger?


 

 

 

 

 

 

 

 

 

 


If you Installed MASM in a Different Directory

You need to open and make a small change to the make16.bat file located in MASM's home directory. You can use Windows NotePad, or any other plain text editor. Following is a listing of the file, minus some of the remark (REM) lines. The very first line shows where MASM is normally installed:

SET MASM=c:\MASM613\


path %MASM%


REM Next, Invoke ml.exe (the Microsoft assembler):


ML /nologo -c -Fl -Zi %1.asm
if errorlevel 1 goto terminate


REM Run the 16-bit linker, and link to the IRVINE.LIB library:


link /NOLOGO /CODEVIEW %1,,,%MASM%Irvine;
if errorlevel 1 goto terminate


REM Display all files related to this program:
dir %1.*

:terminate

(There are quite a few comment lines in the actual file, which you can read to learn about the various command line options used with the assembler and linker.)

Suppose you installed MASM somewhere else, such as: D:\MyMASM

Then all you have to do is change the first line of this file to:

      SET MASM=D:\MyMASM\

(Don't forget the last backslash) Save the file and continue with Step 3 at the beginning of this tutorial, with one change: Everywhere that you see "Masm613" in the instructions, substitute your own directory name.

That should do it.


 

 

 

 

 

 

 


Note about MS-DOS Directory Names and Filenames

Important: The Microsoft linker was written in 1992, so it has rather old-fashioned requirements regarding source code filenames and the path to your working directory (where you keep your ASM files) must conform to the following requirements:

Here are examples of both invalid and valid directory paths:

C:\myprogs\asm\ valid
C:\My Docs\asm\ invalid (contains a space)
D:\asmprogs\ valid
//projects\asm\ invalid (starts with //)
C:\ProgramFiles\asm\ invalid (name is too long)

And finally, the base part of your ASM fileame cannot be longer than 8 characters. The file extension must always be ASM.