Setting up Visual Studio to Assemble Programs1

Visual Studio, the IDE for Microsoft Visual C++ 6.0, can be used to edit assembly language programs, and to launch the Microsoft Assembler and debugger. Here are some important guidelines:

        C:\MASM613\BIN;C:\MASM613\BINR

Let's assume that your computer is set up with the following file locations:

If you have installed these files in other locations, you will need to adjust the commands shown later on this page to the appropriate values.

Step 1: Select Customize from the Tools menu and click on the Tools tab.

Step 2: Scroll to the bottom of the Menu Contents text area and double click inside the dotted rectangle. Type the following name and press Enter:
    Build ASM Program

Enter the following information in each edit box. The Arguments, incidentally, are case-sensitive, as are the variables such as $(FileName):

Command C:\MASM613\BIN\ML.EXE
Arguments /Zi $(FileName).asm /link /co C:\Irvine\Irvine
Initial directory $(FileDir)
(Checked options) Use output window

 

Of course, if you have installed the assembler in a different directory, this is the time to modify the command path accordingly. The same is true for the path to the IRVINE.LIB link library, which is shown here as "C:\IRVINE\IRVINE".

Step 3: Add another command to the menu list:
    Debug ASM Program

Enter the following information in each edit box:

Command C:\MASM613\BINR\CV.EXE
Arguments $(FileName)
Initial directory $(FileDir)
(Checked options) Close window on exiting

Step 4: Add another command to the menu list:
    Execute ASM Program

Enter the following information in each edit box:

Command C:\WINDOWS\COMMAND.COM
Arguments /C $(FileName)
Initial directory $(FileDir)
(Checked options) (none)

Close the Customize window.

Step 5: Test your configuration:

Now either create a new ASM program and save it with an ASM extension, or open an existing ASM file. Select Build ASM Program from the Tools menu. You should see messages from the Microsoft Assembler appear in the output window at the bottom of the screen.

If the program contains a syntax error, double click on the error message. Visual Studio will move the insertion point to the line in the ASM program that caused the error.

Once the program builds correctly, select Debug ASM Program from the Tools menu. Microsoft CodeView will run, and after a few seconds, your source program will appear. You can rearrange the windows and display the registers in CodeView (select Register from the Windows menu, and then select 32-bit Registers from the Options menu).

CodeView creates two files in the same directory as your ASM source program (CLRFILE.CV4, and CURRENT.STS); the latter file saves the window configuration you last used when debugging. You can copy this file to each directory where you plan to debug ASM programs.

Refer to Appendix C of the Irvine book for help in using CodeView.

 

Speeding Up the Debug ASM Command (optional)

You may have noticed in Step 5 that when running CodeView, you had to wait a considerable amount of time for your program's source code to be loaded. This happens because CodeView searches through all directories listed in your system PATH variable. There is a way to make CodeView load much faster. Look in the C:\IRVINE directory for a file named DEBUG.BAT, and for a shortcut named DEBUG (it configures debug.bat). Here is what's in DEBUG.BAT:

	path c:\masm613\bin;c:\masm613\binr
	CV %1

As you can see, the batch file cuts down the system PATH (temporarily) to just two directories. It then runs CodeView, passing it the name of the program to be debugged (%1). When CodeView exits and the batch file returns, your system PATH will be restored to its original value.

To use this batch file, select Customize from the Tools menu and click on the Tools tab. Scroll down to the Debug ASM Program command, and change the Command string to the following:

    C:\IRVINE\DEBUG.BAT

Click the Close button, and you're done. Try the Debug command again, and you should see a dramatic improvement in speed.

 


1Special thanks to Professor Tim Downey of Florida International University for his help in showing me how to do this.