Lab 1: Assembly Language Tools and Data Representation
Lab 1: Assembly Language Tools and Data Representation
Lab 1: Assembly Language Tools and Data Representation
Contents
1.1. Introduction to Assembly Language Tools
1.2. Installing MASM 6.15
1.3. Displaying a Welcome Statement
1.4. Installing the Windows Debugger
1.5. Using the Windows Debugger
1.6. Data Representation
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.
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 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.
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 are done properly, you can start using the
MASM commands.
The first assembly-language program that you will assemble, link, and run is welcome.asm.
This program displays a welcome statement on the screen and terminates. You can open this
program using any text editor. We will not go over the details of this program in this first lab.
You will understand these details in future labs.
.686
.MODEL flat, stdcall
.STACK
INCLUDE Irvine32.inc
.data
.code
main PROC
; Clear the screen
call Clrscr ; Call procedure Clrscr
Console Output
The latest version of the 32-bit Windows debugger is available for download from Microsoft
at http://www.microsoft.com/whdc/devtools/debugging/installx86.mspx. Alternatively, you
can download version 6.5.3.7 (released on June 2005) from
http://www.ccse.kfupm.edu.sa/~mudawar/coe205/lab/index.htm.
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.
Step 4: Open a Command Prompt and type: path. This command should display the value of
the path variable. Make sure to have the installation directory of the debugger C:\Program
Files\Debugging Tools for Windows\ as part of the PATH variable.
Open the source file welcome.asm from the File menu (or click on the button). Place the
cursor at the beginning of the main procedure and press F7 (or click the button) to start
the execution of the main procedure. Press F10 (or click the button) to step through the
execution of the main procedure. Observe the console output as you step through the
execution.
When working with binary numbers, how does the CPU compute the negative of a number?
The answer is that the CPU computes the 2’s complement. The 2’s complement is the
negative of a number. For example, consider the following 8-bit binary number: 00010110,
which is equal to 22 in decimal. The 2’s complement is obtained by reversing each bit of a
binary number (called the 1’s complement) and then adding 1. For example,
2’s complement of 00010110 = 11101001 (1’s complement) + 1 = 11101010
1.6.7 Write each of the following Integers in 8-bit 2’s Complement Notation:
a) -1 = d) -62 =
b) -17 = e) +127 =
c) -19 = f) -128 =
1.6.8 Write each of the following 8-bit Signed Binary Integers in Decimal:
a) 01011100 = d) 01111110 =
b) 11011100 = e) 10010001 =
c) 10001111 = f) 10000000 =
1.6.9 Indicate the sign for each of the following 16-bit signed hex integers:
a) 7FB9 d) 8123
b) D000 d) 6FFF
1.6.10 Write each of the following signed integers as 16-bit hexadecimal value:
a) -1 = c) -256 =
b) -127 = d) -8193 =
b) What is the smallest negative 8-bit value in binary, hexadecimal, and decimal?
c) What is the largest positive 16-bit value in binary, hexadecimal, and decimal?
d) What is the smallest negative 16-bit value in binary, hexadecimal, and decimal?
Review Questions
1. Name four software tools used for assembly language programming:
2. What is an assembler?
3. What is a linker?
4. What is a debugger?
Programming Exercises
1. Modify the welcome.asm program to display a message of your choice.