Getting Started

 

Updated 4/4/2004

Let's assume that you bought my book, and you need to get the Microsoft Assembler and sample programs installed so you can start working.

Step 1

Insert the book's CD-ROM and double-click on the index.html file in the root directory. It explains how to install the assembler, editor, and sample programs.

Run the Setup.exe program in the CD-ROM's root directory.

If your book does not have an enclosed CD-ROM, the book is defective and should be returned to the bookstore. (This particularly applies to used copies of the book.) The CD-ROM cannot be downloaded from any Web site. If your book has the original CD-ROM and the latter is damaged or defective, you can have it replaced. Send the defective disk, along with your name and address, to: Computer Science Editor, Pearson Education, 1 Lake Street, Upper Saddle River, NJ 07458

If you installed the assembler using the default setup path, the Microsoft Assembler and sample programs should be located in the C:\Masm615 directory. If you decide to use a different path, you'll have to modify some of the batch files we use for assembling, linking, and debugging (read the instructions). From this point on, we will refer to the assembler's install path as <masm>.

Step 2

Download and install the Library Update Patch. Also, download the online help file for the library.

Step 3

Create a directory on your hard drive where you would like to do your work. We will call this your working directory from now on.

  • Look for the make32.bat file in the <masm> directory. Copy it to your working directory
  • Look for the AddSub.asm program in the <masm>\Examples\ch03 directory. Copy it to your working directory.
  • Open a DOS/command window. Do this by selecting Run from the Start menu, and run cmd.exe. (If that doesn't work, try running command.com instead.)
  • At the command prompt, move to your working directory. For example, if your directory were D:\myAsm, you would type the following commands, pressing Enter after each:
D:
cd \myAsm

Type the following command to assembe and link the AddSub.asm program:

make32 addsub

(Program names and filenames are not case-sensitive at the command prompt.)

You should see the following output screen. It shows the execution of the Microsoft Assembler, the Linker, and lists all filenames in the current directory beginning with "addsub":

Microsoft (R) Macro Assembler Version 6.15.8803
Copyright (C) Microsoft Corp 1981-2000.  All rights reserved.

 Assembling: addsub.asm
Microsoft (R) Incremental Linker Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

 Volume in drive D is DATA_1
 Volume Serial Number is 5D1D-48A2

 Directory of D:\MyAsm

02/03/2002  10:07a                 316 AddSub.asm
06/22/2002  06:38p               3,388 addsub.obj
06/22/2002  06:38p              13,557 addsub.lst
06/22/2002  06:38p              29,596 addsub.ilk
06/22/2002  06:38p              28,708 addsub.exe
06/22/2002  06:38p              91,136 addsub.pdb
06/22/2002  06:38p               6,052 addsub.map
               7 File(s)        172,753 bytes
               0 Dir(s)   2,053,885,952 bytes free

(Filenames in MS-DOS are not case-sensitive, by the way.)

The file addsub.exe is called the executable program. Run this program by typing addsub at the command prompt. You should see the following:

D:\MyAsm\addsub

  EAX=00030000  EBX=7FFDF000  ECX=00000101  EDX=FFFFFFFF
  ESI=00000000  EDI=007406E8  EBP=0012FFF0  ESP=0012FFC4
  EIP=00401024  EFL=00000206  CF=0  SF=0  ZF=0  OF=0

If you received this output, then you have installed the assembler correctly.

Working at the DOS Prompt

It is possible to do all your editing and assembling from a command prompt, which is the way we always did it when only MS-DOS was around. We will assume that your command window is still open and you're still in the same directory that you used when testing the make32.bat command just now. Type the following command and press Enter:

notepad addsub.asm

This is a screen snapshot of the NotePad editor, containing the AddSub.asm file:

Just for fun, change the first "mov" instruction (on line 11) to "move". Save the file and exit to the DOS prompt. Run the make32.bat file again:

make32 addsub

Notice that this time, the assembler displays an error message that refers to line 11 in the source file:

Microsoft (R) Macro Assembler Version 6.15.8803
Copyright (C) Microsoft Corp 1981-2000. All rights reserved.
 Assembling: addsub.asm
addsub.asm(11) : error A2008: syntax error : eax
Press any key to continue . . .

Of course, the assembler's not too smart. Rather than detecting the misspelling of the MOV instruction, the assembler assumed that you wanted to type MOVE. It just didn't know what to do with EAX that followed on the same line!

And so the process goes. Every time you make a change to the source code, you must save the file and run the make32.bat file again. If you want to save a little time, you can open two command windows and set them to the same directory. Run the editor in one window, and run the make32.bat file in the other one.

Most likely, you will want to use an integrated text editor to create your programs. You will be able to assemble, link, and debug your programs from your editor. Click here to read about the various integrated development environments you can use.

Read the note for Window 98 users.

 

Back to top

 

 

 

 

 

 

 

 


Choosing a Custom Install Path

If you're here, you've decided to install MASM in a location other that C:\Masm. You will need to modify the following files, located in your <masm> directory:

  • make16.bat (for writing 16-bit Real-mode applications)
  • runCV.bat (for running the 16-bit debugger named CodeView)
  • make32.bat (for writing 32-bit Protected-mode applications)
  • runASM.bat (for running a program from an IDE-type editor)

It's not as bad as it sounds. Basically, you must find every occurrence of C:\Masm615 and replace it with the name of your custom directory. Suppose, for example, your custom directory were named C:\Apps\Masm. You would customize the following lines in make32.bat:

   SET PATH=C:\Apps\Masm
   SET INCLUDE=C:\Apps\Masm\INCLUDE
   SET LIB=C:\Apps\Masm\LIB

By the way, if you're concerned that the PATH variable is being permanently changed, don't worry. From Windows 2000 onward, the Windows command shell restores your path to the way it was when the batch file finishes executing. If you're using Windows 98, read the special note.

 

 

 

 

 

 

 

 

 

 

 

 

 


A Note for Windows 98 Users

Windows 98 does not restore its PATH variable when the path is modified by a batch file. So that you don't change your PATH variable by running the make32.bat file, you can try the following workaround: Add the <masm> directory to your permanent path by editing the PATH statement in the Autoexec.bat file in the boot directory. For example, if <masm> were equal to C:\Masm615, for example, your path would look something like this:

	PATH C:\Windows;C:\Windows\Command;C:\Masm615

And so on. You will have to restart your computer. After doing this, you can remove the PATH command from the make32.bat file, leaving only the following two SET statements:

 	SET INCLUDE=C:\Masm615\INCLUDE
	SET LIB=C:\Masm615\LIB