COE 205 Lab Tools

Computer Organization & Assembly Language

 

Prepared during Summer 2005
Muhamed F. Mudawar

mudawar@kfupm.edu.sa

Office: Building 22, Room 328, Phone: 4642

COE 205 Home | Syllabus | Lectures | Assignments | Lab | Manuals

Assembler

An assembler is a program that converts source-code programs written in assembly language into object files in machine language. Popular assemblers have emerged over the years for the Intel family of processors. These include MASM (Macro Assembler from Microsoft), TASM (Turbo Assembler from Borland), NASM (Netwide Assembler for both Windows and Linux), MASM32 (built on top of MASM), Asm86, and GNU assembler distributed by the free software foundation. We will use MASM version 6.15.  Click here to install MASM 6.15.

Linker

A linker is a program that combines your program's object file created by the assembler with other object files and link libraries, and produces a single executable program. You need a linker utility to produce executable files. Two linkers: LINK.EXE and LINK32.EXE are provided with the MASM 6.15 distribution to link 16-bit real-address mode and 32-bit protected-address mode programs respectively.

Debugger

A debugger is a program that allows you to trace the execution of a program and examine the content of registers and memory.

For 16-bit programs, MASM supplies a 16-bit debugger named CodeView. CodeView can be used to debug only 16-bit programs and is already provided with the MASM 6.15 distribution.

For 32-bit protected-mode programs, you need a 32-bit debugger. A 32-bit debugger under Windows is available for free from Microsoft. Click here to install the Windows 32-bit debugger.

Editor

You need a text editor to create assembly language source files. You can use NotePad , or any other editor that produces plain ASCII text files. We will use the ConTEXT editor, which is distributed as a freeware at http://www.context.cx. ConTEXT is a powerful editor that can be easily customized and can be used as a programming environment to program in assembly language. It has built-in syntax highlighting feature. Click here to install ConTEXT.

Installing MASM 6.15

Step 1: Download MASM615.exe. It is a self-extract executable file.

Step 2: Double click on MASM615.exe to extract the files. Specify the installation directory. We recommend using C:\Program Files\MASM615 as the destination directory, but any other directory will do.

Now examine the installation directory C:\Program Files\MASM615\. It should contain the following files:

  • ML.EXE is the assembler (version 6.15). It can assemble 16-bit and 32-bit programs.

  • LINK.EXE is a 16-bit linker used to produce 16-bit real-address mode executable programs.

  • LINK32.EXE is a 32-bit linker used to produce 32-bit protected-address mode programs.

  • make16.bat is a batch file used to assemble and link 16-bit real-address mode programs.

  • make32.bat is used to assemble and link 32-bit protected-address mode programs.

  • CV.EXE is a debugger named CodeView and is used to debug 16-bit programs only.

  • LIB.EXE is the library manager.

  • INCLUDE is a directory that contains include (.inc) files.

  • LIB is a directory that contains link library (.lib) files.

Step 3: Define an environment variable MASMDIR for the installation directory as follows:

Under Control Panel, double-click on System to obtain the System Properties dialog box. Under System Properties, click on the Advanced tab. Click on the Environment Variables button.

Under Environment Variables, Click on the New button to add a New System Variable. Add MASMDIR as the variable name and the C:\Program Files\MASM615 as the variable value and press OK. The MASMDIR variable and its value should now appear under System variables. If a different installation directory is chosen for MASM 6.15 then specify it here.

Step 4: Edit the Path system variable by inserting %MASMDIR%; (don't forget the semicolon) at the beginning of the variable value.

Step 5: Define a new system variable called INCLUDE with value %MASMDIR%\INCLUDE as show below and press OK. This variable specifies the directory that contains the include (.inc) files.

Step 6: Define a new system variable called LIB with value %MASMDIR%\LIB as show below and press OK. This variable specifies the directory that contains the link library (.lib) files.

The newly defined system variables should appear as shown below.

Step 7: Check the environment variables. Open a Command Prompt and type:

  • SET MASMDIR

  • SET INCLUDE

  • SET LIB

  • PATH

These commands should display the MASMDIR, INCLUDE, LIB, and PATH environment variables as shown below. If the installation steps were done properly, you can start using the MASM commands.

Installing the Windows 32-bit Debugger

Step 1: Download the 32-bit debugger installer.

Step 2: Double click on the installer executable file and follow the on-screen instructions.

Step 3: Edit the Path system variable by appending the installation directory of the windows debugger C:\Program Files\Debugging Tools for Windows\ at the end of the Path value. Don't forget to use the semicolon as a separator between various directories in the Path system variable.

Installing ConTEXT

Step 1: Download the ConTEXT editor installer.

Step 2: Run ConTEXTsetup.exe program. This will install the ConTEXT text editor.

Customizing ConTEXT

Step 1: Download the MASM syntax highlighter.

Step 2: Copy the MASM syntax highlighter into the "C:\Program Files\ConTEXT\Highlighters" directory, assuming that you have already installed ConTEXT in the "C:\Program Files\ConTEXT" directory.

Step 3: Start the ConTEXT editor. Select Environment Options ... from the Options menu. You can customize many options of ConTEXT. Click on Editor and select Line numbers to display the line numbers in the editor. Select also the default Highlighter as MASM. Other options can be customized as shown below.

Step 4: Now click on Execute Keys to define new execution keys for assembly language programs. Click on the Add button. This will open the Extension edit dialog box as shown below. Enter asm as the extension for assembly language programs and press OK. You can now define four execution keys (F9, F10, F11, and F12) to execute various commands. We will define these keys to assemble, link, and debug assembly language programs, as described below.

Step 5: Define the F9 key as shown below. This will execute the make32.bat batch file under the "C:\Program Files\MASM615\" directory, where MASM has been installed. This batch file will Assemble and Link 32-bit Programs. Write this information in the Hint field and fill-in and select the fields as shown below.

Step 6: Define the F10 key as shown below. This will execute the make16.bat batch file under the "C:\Program Files\MASM615\" directory, where MASM has been installed. This batch file will Assemble and Link 16-bit Programs. Write this information in the Hint field and fill-in and select the fields as shown below.

Step 7: Define the F11 key as shown below. This key will be used to start the 32-bit Windows Debugger. Enter C:\Program Files\Debugging Tools for Windows\windbg.exe under the Execute field. Enter also -QY -G %F.exe under Parameters as shown.

Step 8: Define the F12 key as shown below. This key will be used to start the 16-bit CodeView Debugger. Enter C:\Program Files\MASM615\CV.exe under the Execute field. Enter also /50 %F under Parameters as shown. Now press OK to apply the changes and start using the newly defined execution keys.

Step 9: Now open any .asm file with ConTEXT. You can make this association by clicking on the right mouse-button and select Open With ... and selecting ConTEXT. Also select the checkbox: Always use the selected program to open this kind of file to make this association permanent.

This is how an assembly language program looks like in ConTEXT. Make sure to select the MASM highlighter. You may change these colors if you don't like them, by selecting the Colors tab under Environment Options.

Enjoy using these tools and your assembly language course.

 

  Last Updated: Sunday October 05, 2008, by Dr. Muhamed Mudawar